Skip to content

New Resource: azurerm_compute_fleet#28758

Closed
sinbai wants to merge 13 commits intohashicorp:mainfrom
sinbai:computefleet/new_resource
Closed

New Resource: azurerm_compute_fleet#28758
sinbai wants to merge 13 commits intohashicorp:mainfrom
sinbai:computefleet/new_resource

Conversation

@sinbai
Copy link
Copy Markdown
Contributor

@sinbai sinbai commented Feb 12, 2025

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

API: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/azurefleet/resource-manager/Microsoft.AzureFleet/stable/2024-11-01/azurefleet.json

Doc: https://learn.microsoft.com/en-us/azure/azure-compute-fleet/overview

Note: TC test subscription account needs to register Microsoft.AzureFleet namespace

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • [] I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevant documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

PASS: TestAccComputeFleet_virtualMachineProfileImage_imageFromSharedImageGalleryVersion (1674.34s)
PASS: TestAccComputeFleet_virtualMachineProfileImage_imageFromSharedImageGallery (1618.08s)
PASS: TestAccComputeFleet_virtualMachineProfileImage_imageFromCommunitySharedImageGalleryVersion (1720.16s)
PASS: TestAccComputeFleet_virtualMachineProfileImage_imageFromCommunitySharedImageGallery (1772.22s)
PASS: TestAccComputeFleet_virtualMachineProfileImage_imageFromImageId (688.07s)
PASS: TestAccComputeFleet_virtualMachineProfileImage_imageFromImageSourceReference (583.79s)
PASS: TestAccComputeFleet_virtualMachineProfileExtensions_complete (238.23s)
PASS: TestAccComputeFleet_virtualMachineProfileExtensions_protectedSettingsFromKeyVault (768.25s)
PASS: TestAccComputeFleet_virtualMachineProfileExtensions_basic (233.85s)
PASS: TestAccComputeFleet_virtualMachineProfileExtensions_update (548.34s)
PASS: TestAccComputeFleet_virtualMachineProfileAuth_authMultipleSSHPublicKeys (616.67s)
PASS: TestAccComputeFleet_virtualMachineProfileAuth_authSSHKey (612.78s)
PASS: TestAccComputeFleet_virtualMachineProfileAuth_authPassword (491.86s)
PASS: TestAccComputeFleet_virtualMachineProfileAuth_authEd25519SSHPublicKeys (446.14s)
PASS: TestAccComputeFleet_virtualMachineProfileAuth_authSSHKeyAndPassword (433.36s)
PASS: TestAccComputeFleet_completeExceptVMSS (323.73s)
PASS: TestAccComputeFleet_update (503.19s)
PASS: TestAccComputeFleet_requiresImport (304.98s)
PASS: TestAccComputeFleet_basic (276.35s)
PASS: TestAccComputeFleet_virtualMachineProfileOthers_UserData (544.01s)
PASS: TestAccComputeFleet_virtualMachineProfileOthers_scheduledEvent (550.24s)
PASS: TestAccComputeFleet_virtualMachineProfileOthers_licenseType (560.89s)
PASS: TestAccComputeFleet_virtualMachineProfileOthers_bootDiagnosticEnabled (537.74s)
PASS: TestAccComputeFleet_virtualMachineProfileOthers_galleryApplication (1636.13s)
PASS: TestAccComputeFleet_virtualMachineProfileOthers_securityProfile (409.62s)
PASS: TestAccComputeFleet_virtualMachineProfileOthers_additionalCapabilitiesHibernation (359.61s)
PASS: TestAccComputeFleet_virtualMachineProfileOthers_additionalCapabilitiesUltraSSD (357.57s)
PASS: TestAccComputeFleet_virtualMachineProfileOsProfile_windowsUpdate (774.72s)
PASS: TestAccComputeFleet_virtualMachineProfileOsProfile_windowsComplete (623.81s)
PASS: TestAccComputeFleet_virtualMachineProfileOsProfile_linuxBasic (322.43s)
PASS: TestAccComputeFleet_virtualMachineProfileOsProfile_linuxUpdate (1631.18s)
PASS: TestAccComputeFleet_virtualMachineProfileOsProfile_windowsBasic (360.23s)
PASS: TestAccComputeFleet_virtualMachineProfileOsProfile_linuxComplete (532.94s)
PASS: TestAccComputeFleet_virtualMachineProfileOsDisk_complete (536.28s)
PASS: TestAccComputeFleet_virtualMachineProfileOsDisk_update (1235.23s)
PASS: TestAccComputeFleet_virtualMachineProfileOsDisk_basic (330.43s)
PASS: TestAccComputeFleet_virtualMachineProfileNetwork_basic (379.29s)
PASS: TestAccComputeFleet_virtualMachineProfileNetwork_updateForBaseVirtualMachineProfile (1878.72s)
PASS: TestAccComputeFleet_virtualMachineProfileNetwork_updateForAdditionalLocation (2297.68s)
PASS: TestAccComputeFleet_virtualMachineProfileNetwork_completeForBaseVirtualMachineProfile (836.75s)
PASS: TestAccComputeFleet_virtualMachineProfileNetwork_completeForAdditionalLocation (848.91s)
PASS: TestAccComputeFleet_virtualMachineProfileDataDisk_basic (360.75s)
PASS: TestAccComputeFleet_virtualMachineProfileDataDisk_complete (469.06s)
PASS: TestAccComputeFleet_virtualMachineProfileDataDisk_update (1296.47s)

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

  • azurerm_compute_fleet - new resource

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Copy link
Copy Markdown
Collaborator

@ms-zhenhua ms-zhenhua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sinbai ,

Thanks for this PR - I've taken a look through and left some comments. If we can fix those up, this should be good to go 👍

ForceNew: true,
},

"vm_attributes": vmAttributesSchema(),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we define the schema inline as it's not reused in other places?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Optional: true,
ForceNew: true,
Default: string(fleets.RegularPriorityAllocationStrategyLowestPrice),
ValidateFunc: validation.StringInSlice([]string{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a PossibleValuesFor... method for this enum?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Optional: true,
ForceNew: true,
Default: string(fleets.SpotAllocationStrategyPriceCapacityOptimized),
ValidateFunc: validation.StringInSlice([]string{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a PossibleValuesFor... method for this enum?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Optional: true,
ForceNew: true,
Default: string(fleets.EvictionPolicyDelete),
ValidateFunc: validation.StringInSlice([]string{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a PossibleValuesFor... method for this enum?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}
}

if a := model.AdditionalLocationProfile; len(a) > 0 && len(a[0].VirtualMachineProfileOverride) > 0 {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if a := model.AdditionalLocationProfile; len(a) > 0 && len(a[0].VirtualMachineProfileOverride) > 0 {
if additionalLocationProfile := model.AdditionalLocationProfile; len(additionalLocationProfile) > 0 && len(additionalLocationProfile[0].VirtualMachineProfileOverride) > 0 {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


* `additional_unattend_content` - (Optional) One or more `additional_unattend_content` blocks as defined above.

* `automatic_updates_enabled` - (Optional) Should the automatic updates of the virtual machines be enabled? Defaults to `true`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `automatic_updates_enabled` - (Optional) Should the automatic updates of the virtual machines be enabled? Defaults to `true`.
* `automatic_updates_enabled` - (Optional) Whether to enable the automatic updates of the virtual machines. Defaults to `true`.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


* `automatic_updates_enabled` - (Optional) Should the automatic updates of the virtual machines be enabled? Defaults to `true`.

* `bypass_platform_safety_checks_enabled` - (Optional) Should the customer to schedule patching without accidental upgrades be enabled? Defaults to `false`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as linux_configuration

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


* `bypass_platform_safety_checks_enabled` - (Optional) Should the customer to schedule patching without accidental upgrades be enabled? Defaults to `false`.

* `hot_patching_enabled` - (Optional) Should the customers to patch the virtual machines without requiring a reboot be enabled? Defaults to `false`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `hot_patching_enabled` - (Optional) Should the customers to patch the virtual machines without requiring a reboot be enabled? Defaults to `false`.
* `hot_patching_enabled` - (Optional) Whether to enable the customers to patch the virtual machines without requiring a reboot. Defaults to `false`.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


* `patch_mode` - (Optional) Specifies the mode of in-guest patching of the virtual machines. Possible values are `AutomaticByOS`, `AutomaticByPlatform` and `Manual`.

* `provision_vm_agent_enabled` - (Optional) Should the virtual machine agent be provisioned on each virtual machine in the Scale Set? Defaults to `true`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as linux_configuration

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


* `time_zone` - (Optional) Specifies the time zone of the windows virtual machine. Changing this forces a new resource to be created.

* `vm_agent_platform_updates_enabled` - (Optional) Should the virtual machine agent platform updates be enabled for the windows virtual machine? Defaults to `false`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as linux_configuration

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

"github.com/hashicorp/terraform-provider-azurerm/utils"
)

func virtualMachineProfileSchema() *pluginsdk.Schema {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this schema be moved into the rest of the explicit definition? It seems this function is only called once.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


* `provision_vm_agent_enabled` - (Optional) Whether to provision the virtual machine agent on each virtual machine in the Scale Set. Defaults to `true`. Changing this forces a new resource to be created.

* `reboot_setting` - (Optional) Specifies the reboot setting for all `AutomaticByPlatform` patch installation operations. Possible values are `Always`, `IfRequired`, `Never` and `Unknown`. Changing this forces a new resource to be created.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `reboot_setting` - (Optional) Specifies the reboot setting for all `AutomaticByPlatform` patch installation operations. Possible values are `Always`, `IfRequired`, `Never` and `Unknown`. Changing this forces a new resource to be created.
* `patch_rebooting` - (Optional) Specifies the reboot setting for all `AutomaticByPlatform` patch installation operations. Possible values are `Always`, `IfRequired`, `Never` and `Unknown`. Changing this forces a new resource to be created.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


* `plan` - (Optional) A `plan` block as defined below. Changing this forces a new resource to be created.

* `platform_fault_domain_count` - (Optional) Specifies the number of fault domains that are used by the Compute Fleet. Defaults to `1`. Changing this forces a new resource to be created.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `platform_fault_domain_count` - (Optional) Specifies the number of fault domains that are used by the Compute Fleet. Defaults to `1`. Changing this forces a new resource to be created.
* `platform_fault_domain_count` - (Optional) Specifies the number of fault domains that are used by the Compute Fleet. Defaults to `1`. Changing this forces a new resource to be created.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

* `spot_priority_profile` - (Optional) A `spot_priority_profile` block as defined below.

* `tags` - (Optional) A mapping of tags which should be assigned to the Compute Fleet.
*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


* `extension` - (Optional) One or more `extension` blocks as defined above. Changing this forces a new resource to be created.

* `extension_operations_enabled` - (Optional) Whether to enable extension operations on the Compute Fleet. Defaults to `true`. Changing this forces a new resource to be created.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `extension_operations_enabled` - (Optional) Whether to enable extension operations on the Compute Fleet. Defaults to `true`. Changing this forces a new resource to be created.
* `extension_operations_enabled` - (Optional) Whether to enable extension operations on the Compute Fleet. Defaults to `true`. Changing this forces a new resource to be created.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


A `network_interface` block supports the following:

* `name` - (Required) The name which should be used for the network interface. Changing this forces a new resource to be created.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `name` - (Required) The name which should be used for the network interface. Changing this forces a new resource to be created.
* `name` - (Required) The name which should be used for the network interface. Changing this forces a new resource to be created.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


A `additional_capabilities` block supports the following:

* `hibernation_enabled` - (Optional) Whether to enable the hibernation capability on the Compute Fleet. Defaults to `false`. Changing this forces a new resource to be created.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `hibernation_enabled` - (Optional) Whether to enable the hibernation capability on the Compute Fleet. Defaults to `false`. Changing this forces a new resource to be created.
* `hibernation_enabled` - (Optional) Whether to enable the hibernation capability on the Compute Fleet. Defaults to `false`. Changing this forces a new resource to be created.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


* `disk_encryption_set_id` - (Optional) The ID of the disk encryption set which should be used to encrypt the data disk. Changing this forces a new resource to be created.

* `disk_size_in_gib` - (Optional) The size of the data disk which should be created. Changing this forces a new resource to be created.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe indicate the unit once more in the description to emphasize the differentiation from GB?

Suggested change
* `disk_size_in_gib` - (Optional) The size of the data disk which should be created. Changing this forces a new resource to be created.
* `disk_size_in_gib` - (Optional) The size of the data disk which should be created in GiB. Changing this forces a new resource to be created.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


-> **Note:** Required if `create_option` is specified as `Empty`.

* `storage_account_type` - (Optional) The type of storage account which should back the data disk. Possible values include `Premium_LRS`, `PremiumV2_LRS`, `Premium_ZRS`, `Standard_LRS`, `StandardSSD_LRS`, `StandardSSD_ZRS` and `UltraSSD_LRS`. Changing this forces a new resource to be created.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `storage_account_type` - (Optional) The type of storage account which should back the data disk. Possible values include `Premium_LRS`, `PremiumV2_LRS`, `Premium_ZRS`, `Standard_LRS`, `StandardSSD_LRS`, `StandardSSD_ZRS` and `UltraSSD_LRS`. Changing this forces a new resource to be created.
* `storage_account_type` - (Optional) The type of storage account which should back the data disk. Possible values include `Premium_LRS`, `PremiumV2_LRS`, `Premium_ZRS`, `Standard_LRS`, `StandardSSD_LRS`, `StandardSSD_ZRS` and `UltraSSD_LRS`. Changing this forces a new resource to be created.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


A `identity` block supports the following:

* `type` - (Required) The type of managed identity that should be configured on the Compute Fleet. The only possible value is `UserAssigned`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `type` - (Required) The type of managed identity that should be configured on the Compute Fleet. The only possible value is `UserAssigned`.
* `type` - (Required) The type of managed identity that should be configured on the Compute Fleet. The only possible value is `UserAssigned`.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


* `hot_patching_enabled` - (Optional) Whether to enable the customers to patch the virtual machines without requiring a reboot. Defaults to `false`. Changing this forces a new resource to be created.

* `patch_mode` - (Optional) Specifies the mode of in-guest patching of the virtual machines. Possible values are `AutomaticByOS`, `AutomaticByPlatform` and `Manual`. Changing this forces a new resource to be created.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `patch_mode` - (Optional) Specifies the mode of in-guest patching of the virtual machines. Possible values are `AutomaticByOS`, `AutomaticByPlatform` and `Manual`. Changing this forces a new resource to be created.
* `patch_mode` - (Optional) Specifies the mode of in-guest patching of the virtual machines. Possible values are `AutomaticByOS`, `AutomaticByPlatform` and `Manual`. Changing this forces a new resource to be created.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


* `vm_agent_platform_updates_enabled` - (Optional) Whether to enable the virtual machine agent platform updates for the windows virtual machine in the Compute Fleet. Defaults to `false`. Changing this forces a new resource to be created.

* `winrm_listener` - (Optional) One or more `winrm_listener` blocks as defined below. Changing this forces a new resource to be created.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `winrm_listener` - (Optional) One or more `winrm_listener` blocks as defined below. Changing this forces a new resource to be created.
* `winrm_listener` - (Optional) One or more `winrm_listener` blocks as defined below. Changing this forces a new resource to be created.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -0,0 +1,37 @@
package computefleet
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
package computefleet
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package computefleet

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


if len(state.SpotPriorityProfile) > 0 && len(state.RegularPriorityProfile) > 0 {
if state.SpotPriorityProfile[0].Capacity+state.RegularPriorityProfile[0].Capacity > 10000 {
return fmt.Errorf("the sum of `spot_priority_profile.0.capacity` and `regular_priority_profile.0.capacity` must be between `0` and `10000`, inclusive")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When not using a format string for an error message, you can simplify and use errors.New() (make sure to import errors)

Suggested change
return fmt.Errorf("the sum of `spot_priority_profile.0.capacity` and `regular_priority_profile.0.capacity` must be between `0` and `10000`, inclusive")
return errors.New("the sum of `spot_priority_profile.0.capacity` and `regular_priority_profile.0.capacity` must be between `0` and `10000`, inclusive")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

if len(state.SpotPriorityProfile) > 0 {
if state.SpotPriorityProfile[0].MaintainCapacityEnabled {
if state.SpotPriorityProfile[0].MinCapacity > 0 {
return fmt.Errorf("`spot_priority_profile.0.min_capacity` is unable to be specified if `spot_priority_profile.0.maintain_enabled` is enabled")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("`spot_priority_profile.0.min_capacity` is unable to be specified if `spot_priority_profile.0.maintain_enabled` is enabled")
return errors.New("`spot_priority_profile.0.min_capacity` is unable to be specified if `spot_priority_profile.0.maintain_enabled` is enabled")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}

if len(state.VMSizesProfile) < 3 {
return fmt.Errorf("`vm_sizes_profile` must be at least 3 Vm sizes if `spot_priority_profile.0.maintain_enabled` is enabled")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("`vm_sizes_profile` must be at least 3 Vm sizes if `spot_priority_profile.0.maintain_enabled` is enabled")
return errors.New("`vm_sizes_profile` must be at least 3 Vm sizes if `spot_priority_profile.0.maintain_enabled` is enabled")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}

if len(state.Zones) == 0 {
return fmt.Errorf("enabling `spot_priority_profile.0.maintain_enabled` requires all qualified availability zones in the region to be supported")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("enabling `spot_priority_profile.0.maintain_enabled` requires all qualified availability zones in the region to be supported")
return errors.New("enabling `spot_priority_profile.0.maintain_enabled` requires all qualified availability zones in the region to be supported")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}

if state.SpotPriorityProfile[0].MinCapacity > state.SpotPriorityProfile[0].Capacity {
return fmt.Errorf("`spot_priority_profile.0.min_capacity` must be between `0` and `spot_priority_profile.0.capacity`, inclusive")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("`spot_priority_profile.0.min_capacity` must be between `0` and `spot_priority_profile.0.capacity`, inclusive")
return errors.New("`spot_priority_profile.0.min_capacity` must be between `0` and `spot_priority_profile.0.capacity`, inclusive")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


if len(state.RegularPriorityProfile) > 0 {
if state.RegularPriorityProfile[0].MinCapacity > state.RegularPriorityProfile[0].Capacity {
return fmt.Errorf("`RegularPriorityProfile.0.min_capacity` must be between `0` and `RegularPriorityProfile.0.capacity`, inclusive")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("`RegularPriorityProfile.0.min_capacity` must be between `0` and `RegularPriorityProfile.0.capacity`, inclusive")
return errors.New("`RegularPriorityProfile.0.min_capacity` must be between `0` and `RegularPriorityProfile.0.capacity`, inclusive")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}

if !ultraSSDEnabled && storageAccountType == string(fleets.StorageAccountTypesUltraSSDLRS) {
return fmt.Errorf("`UltraSSD_LRS` storage account type can be used only when `ultra_ssd_enabled` is enalbed")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("`UltraSSD_LRS` storage account type can be used only when `ultra_ssd_enabled` is enalbed")
return errors.New("`UltraSSD_LRS` storage account type can be used only when `ultra_ssd_enabled` is enabled")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


if v[0].CreateOption == string(fleets.DiskCreateOptionTypesEmpty) {
if v[0].DiskSizeInGiB == 0 {
return fmt.Errorf("`disk_size_in_gib` is required when`create_option` is `Empty`")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("`disk_size_in_gib` is required when`create_option` is `Empty`")
return errors.New("`disk_size_in_gib` is required when`create_option` is `Empty`")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


lunExist := metadata.ResourceDiff.GetRawConfig().AsValueMap()["virtual_machine_profile"].AsValueSlice()[0].AsValueMap()["data_disk"].AsValueSlice()[0].AsValueMap()["lun"]
if lunExist.IsNull() {
return fmt.Errorf("`lun` is required when`create_option` is `Empty`")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("`lun` is required when`create_option` is `Empty`")
return errors.New("`lun` is required when`create_option` is `Empty`")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


vmProfile := state.VirtualMachineProfile[0]
if vmProfile.SourceImageId != "" && len(vmProfile.SourceImageReference) > 0 {
return fmt.Errorf("only one of `source_image_id` and `source_image_reference` in `virtual_machine_profile` must be specified")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("only one of `source_image_id` and `source_image_reference` in `virtual_machine_profile` must be specified")
return errors.New("only one of `source_image_id` and `source_image_reference` in `virtual_machine_profile` must be specified")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


for _, v := range state.VirtualMachineProfile[0].Extension {
if v.ProtectedSettingsJson != "" && len(v.ProtectedSettingsFromKeyVault) > 0 {
return fmt.Errorf("`protected_settings_from_key_vault` cannot be used with `protected_settings_json`")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("`protected_settings_from_key_vault` cannot be used with `protected_settings_json`")
return errors.New("`protected_settings_from_key_vault` cannot be used with `protected_settings_json`")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}

if len(state.Zones) > 0 && state.PlatformFaultDomainCount > 1 {
return fmt.Errorf("specifying `zones` is not allowed when `platform_fault_domain_count` higher than 1")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("specifying `zones` is not allowed when `platform_fault_domain_count` higher than 1")
return errors.New("specifying `zones` is not allowed when `platform_fault_domain_count` higher than 1")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Copy Markdown
Contributor

@wyattfry wyattfry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sinbai thanks for working on this eagerly awaited feature. I left some proposed changes for you.

@sinbai
Copy link
Copy Markdown
Contributor Author

sinbai commented Oct 10, 2025

Hi @sinbai thanks for working on this eagerly awaited feature. I left some proposed changes for you.

Hi @wyattfry thanks for your feedback. I've addressed the comments, could you please take another look?

@gerrytan
Copy link
Copy Markdown
Collaborator

Work on this new resource will continue in #32174 as we no longer have permission to push into this branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.