New Resource: azurerm_compute_fleet#28758
Conversation
11921e3 to
9c5d809
Compare
9c5d809 to
b18cc54
Compare
b18cc54 to
12b281e
Compare
12b281e to
16ace17
Compare
ms-zhenhua
left a comment
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
shall we define the schema inline as it's not reused in other places?
| Optional: true, | ||
| ForceNew: true, | ||
| Default: string(fleets.RegularPriorityAllocationStrategyLowestPrice), | ||
| ValidateFunc: validation.StringInSlice([]string{ |
There was a problem hiding this comment.
is there a PossibleValuesFor... method for this enum?
| Optional: true, | ||
| ForceNew: true, | ||
| Default: string(fleets.SpotAllocationStrategyPriceCapacityOptimized), | ||
| ValidateFunc: validation.StringInSlice([]string{ |
There was a problem hiding this comment.
is there a PossibleValuesFor... method for this enum?
| Optional: true, | ||
| ForceNew: true, | ||
| Default: string(fleets.EvictionPolicyDelete), | ||
| ValidateFunc: validation.StringInSlice([]string{ |
There was a problem hiding this comment.
is there a PossibleValuesFor... method for this enum?
| } | ||
| } | ||
|
|
||
| if a := model.AdditionalLocationProfile; len(a) > 0 && len(a[0].VirtualMachineProfileOverride) > 0 { |
There was a problem hiding this comment.
| if a := model.AdditionalLocationProfile; len(a) > 0 && len(a[0].VirtualMachineProfileOverride) > 0 { | |
| if additionalLocationProfile := model.AdditionalLocationProfile; len(additionalLocationProfile) > 0 && len(additionalLocationProfile[0].VirtualMachineProfileOverride) > 0 { |
|
|
||
| * `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`. |
There was a problem hiding this comment.
| * `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`. |
|
|
||
| * `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`. |
There was a problem hiding this comment.
same as linux_configuration
|
|
||
| * `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`. |
There was a problem hiding this comment.
| * `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`. |
|
|
||
| * `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`. |
There was a problem hiding this comment.
same as linux_configuration
|
|
||
| * `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`. |
There was a problem hiding this comment.
same as linux_configuration
| "github.com/hashicorp/terraform-provider-azurerm/utils" | ||
| ) | ||
|
|
||
| func virtualMachineProfileSchema() *pluginsdk.Schema { |
There was a problem hiding this comment.
Could this schema be moved into the rest of the explicit definition? It seems this function is only called once.
|
|
||
| * `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. |
There was a problem hiding this comment.
| * `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. |
|
|
||
| * `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. |
There was a problem hiding this comment.
| * `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. |
| * `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. | ||
| * |
|
|
||
| * `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. |
There was a problem hiding this comment.
| * `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. |
|
|
||
| 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. |
There was a problem hiding this comment.
| * `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. |
|
|
||
| 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. |
There was a problem hiding this comment.
| * `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. |
|
|
||
| * `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. |
There was a problem hiding this comment.
Maybe indicate the unit once more in the description to emphasize the differentiation from GB?
| * `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. |
|
|
||
| -> **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. |
There was a problem hiding this comment.
| * `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. |
|
|
||
| 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`. |
There was a problem hiding this comment.
| * `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`. |
|
|
||
| * `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. |
There was a problem hiding this comment.
| * `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. |
|
|
||
| * `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. |
There was a problem hiding this comment.
| * `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. |
| @@ -0,0 +1,37 @@ | |||
| package computefleet | |||
There was a problem hiding this comment.
| package computefleet | |
| // Copyright (c) HashiCorp, Inc. | |
| // SPDX-License-Identifier: MPL-2.0 | |
| package computefleet |
|
|
||
| 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") |
There was a problem hiding this comment.
When not using a format string for an error message, you can simplify and use errors.New() (make sure to import errors)
| 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") |
| 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") |
There was a problem hiding this comment.
| 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") |
| } | ||
|
|
||
| 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") |
There was a problem hiding this comment.
| 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") |
| } | ||
|
|
||
| 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") |
There was a problem hiding this comment.
| 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") |
| } | ||
|
|
||
| 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") |
There was a problem hiding this comment.
| 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") |
|
|
||
| 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") |
There was a problem hiding this comment.
| 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") |
| } | ||
|
|
||
| if !ultraSSDEnabled && storageAccountType == string(fleets.StorageAccountTypesUltraSSDLRS) { | ||
| return fmt.Errorf("`UltraSSD_LRS` storage account type can be used only when `ultra_ssd_enabled` is enalbed") |
There was a problem hiding this comment.
| 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") |
|
|
||
| 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`") |
There was a problem hiding this comment.
| 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`") |
|
|
||
| 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`") |
There was a problem hiding this comment.
| return fmt.Errorf("`lun` is required when`create_option` is `Empty`") | |
| return errors.New("`lun` is required when`create_option` is `Empty`") |
|
|
||
| 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") |
There was a problem hiding this comment.
| 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") |
|
|
||
| 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`") |
There was a problem hiding this comment.
| 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`") |
| } | ||
|
|
||
| if len(state.Zones) > 0 && state.PlatformFaultDomainCount > 1 { | ||
| return fmt.Errorf("specifying `zones` is not allowed when `platform_fault_domain_count` higher than 1") |
There was a problem hiding this comment.
| 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") |
|
Work on this new resource will continue in #32174 as we no longer have permission to push into this branch. |
Community Note
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
For example: “
resource_name_here- description of change e.g. adding propertynew_property_name_here”Changes to existing Resource / Data Source
Testing
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_compute_fleet- new resourceThis is a (please select all that apply):