diff --git a/internal/services/compute/linux_virtual_machine_scale_set_other_resource_test.go b/internal/services/compute/linux_virtual_machine_scale_set_other_resource_test.go index 7bb76c0685b7f..1e5bec195454a 100644 --- a/internal/services/compute/linux_virtual_machine_scale_set_other_resource_test.go +++ b/internal/services/compute/linux_virtual_machine_scale_set_other_resource_test.go @@ -452,7 +452,7 @@ func TestAccLinuxVirtualMachineScaleSet_otherTerminationNotification(t *testing. }) } -// TODO remove TestAccLinuxVirtualMachineScaleSet_otherTerminationNotificationMigration in 3.0 +// TODO remove TestAccLinuxVirtualMachineScaleSet_otherTerminationNotificationMigration in 4.0 func TestAccLinuxVirtualMachineScaleSet_otherTerminationNotificationMigration(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_linux_virtual_machine_scale_set", "test") r := LinuxVirtualMachineScaleSetResource{} @@ -1936,7 +1936,7 @@ resource "azurerm_linux_virtual_machine_scale_set" "test" { `, r.template(data), data.RandomInteger) } -// TODO remove otherTerminateNotification in 3.0 +// TODO remove otherTerminateNotification in 4.0 func (r LinuxVirtualMachineScaleSetResource) otherTerminateNotification(data acceptance.TestData, enabled bool) string { return fmt.Sprintf(` %s diff --git a/internal/services/compute/linux_virtual_machine_scale_set_resource.go b/internal/services/compute/linux_virtual_machine_scale_set_resource.go index 46edba66f4dc9..16702db5dad3e 100644 --- a/internal/services/compute/linux_virtual_machine_scale_set_resource.go +++ b/internal/services/compute/linux_virtual_machine_scale_set_resource.go @@ -48,263 +48,7 @@ func resourceLinuxVirtualMachineScaleSet() *pluginsdk.Resource { // TODO: exposing requireGuestProvisionSignal once it's available // https://github.com/Azure/azure-rest-api-specs/pull/7246 - Schema: map[string]*pluginsdk.Schema{ - "name": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validate.VirtualMachineName, - }, - - "resource_group_name": azure.SchemaResourceGroupName(), - - "location": azure.SchemaLocation(), - - // Required - "admin_username": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - "network_interface": VirtualMachineScaleSetNetworkInterfaceSchema(), - - "os_disk": VirtualMachineScaleSetOSDiskSchema(), - - "instances": { - Type: pluginsdk.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(0), - }, - - "sku": { - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - // Optional - "additional_capabilities": VirtualMachineScaleSetAdditionalCapabilitiesSchema(), - - "admin_password": { - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - Sensitive: true, - DiffSuppressFunc: adminPasswordDiffSuppressFunc, - }, - - "admin_ssh_key": SSHKeysSchema(false), - - "automatic_os_upgrade_policy": VirtualMachineScaleSetAutomatedOSUpgradePolicySchema(), - - "automatic_instance_repair": VirtualMachineScaleSetAutomaticRepairsPolicySchema(), - - "boot_diagnostics": bootDiagnosticsSchema(), - - "computer_name_prefix": { - Type: pluginsdk.TypeString, - Optional: true, - - // Computed since we reuse the VM name if one's not specified - Computed: true, - ForceNew: true, - - ValidateFunc: validate.LinuxComputerNamePrefix, - }, - - "custom_data": base64.OptionalSchema(false), - - "data_disk": VirtualMachineScaleSetDataDiskSchema(), - - "disable_password_authentication": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: true, - }, - - "do_not_run_extensions_on_overprovisioned_machines": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: false, - }, - - "edge_zone": commonschema.EdgeZoneOptionalForceNew(), - - "encryption_at_host_enabled": { - Type: pluginsdk.TypeBool, - Optional: true, - }, - - "eviction_policy": { - // only applicable when `priority` is set to `Spot` - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - string(compute.VirtualMachineEvictionPolicyTypesDeallocate), - string(compute.VirtualMachineEvictionPolicyTypesDelete), - }, false), - }, - - "extension": VirtualMachineScaleSetExtensionsSchema(), - - "extensions_time_budget": { - Type: pluginsdk.TypeString, - Optional: true, - Default: "PT1H30M", - ValidateFunc: azValidate.ISO8601DurationBetween("PT15M", "PT2H"), - }, - - "health_probe_id": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: azure.ValidateResourceID, - }, - - "identity": commonschema.SystemAssignedUserAssignedIdentityOptional(), - - "max_bid_price": { - Type: pluginsdk.TypeFloat, - Optional: true, - Default: -1, - ValidateFunc: validate.SpotMaxPrice, - }, - - "overprovision": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: true, - }, - - "plan": planSchema(), - - "platform_fault_domain_count": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - Computed: true, - }, - - "priority": { - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - Default: string(compute.VirtualMachinePriorityTypesRegular), - ValidateFunc: validation.StringInSlice([]string{ - string(compute.VirtualMachinePriorityTypesRegular), - string(compute.VirtualMachinePriorityTypesSpot), - }, false), - }, - - "provision_vm_agent": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: true, - ForceNew: true, - }, - - "proximity_placement_group_id": { - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: validate.ProximityPlacementGroupID, - // the Compute API is broken and returns the Resource Group name in UPPERCASE :shrug:, github issue: https://github.com/Azure/azure-rest-api-specs/issues/10016 - DiffSuppressFunc: suppress.CaseDifference, - }, - - "rolling_upgrade_policy": VirtualMachineScaleSetRollingUpgradePolicySchema(), - - "secret": linuxSecretSchema(), - - "secure_boot_enabled": { - Type: pluginsdk.TypeBool, - Optional: true, - ForceNew: true, - }, - - "single_placement_group": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: true, - }, - - "source_image_id": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: validation.Any( - validate.ImageID, - validate.SharedImageID, - validate.SharedImageVersionID, - ), - }, - - "source_image_reference": sourceImageReferenceSchema(false), - - "tags": tags.Schema(), - - "upgrade_mode": { - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - Default: string(compute.UpgradeModeManual), - ValidateFunc: validation.StringInSlice([]string{ - string(compute.UpgradeModeAutomatic), - string(compute.UpgradeModeManual), - string(compute.UpgradeModeRolling), - }, false), - }, - - "user_data": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: validation.StringIsBase64, - }, - - "vtpm_enabled": { - Type: pluginsdk.TypeBool, - Optional: true, - ForceNew: true, - }, - - "zone_balance": { - Type: pluginsdk.TypeBool, - Optional: true, - ForceNew: true, - Default: false, - }, - - "scale_in_policy": { - Type: pluginsdk.TypeString, - Optional: true, - Default: string(compute.VirtualMachineScaleSetScaleInRulesDefault), - ValidateFunc: validation.StringInSlice([]string{ - string(compute.VirtualMachineScaleSetScaleInRulesDefault), - string(compute.VirtualMachineScaleSetScaleInRulesNewestVM), - string(compute.VirtualMachineScaleSetScaleInRulesOldestVM), - }, false), - }, - - // TODO remove terminate_notification in 3.0 - "terminate_notification": VirtualMachineScaleSetTerminateNotificationSchema(), - - "termination_notification": VirtualMachineScaleSetTerminationNotificationSchema(), - - "zones": func() *schema.Schema { - if !features.ThreePointOhBeta() { - return azure.SchemaZones() - } - - return commonschema.ZonesMultipleOptionalForceNew() - }(), - - // Computed - "unique_id": { - Type: pluginsdk.TypeString, - Computed: true, - }, - }, + Schema: resourceLinuxVirtualMachineScaleSetSchema(), } } @@ -530,9 +274,10 @@ func resourceLinuxVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData, meta i return fmt.Errorf("an `eviction_policy` must be specified when `priority` is set to `Spot`") } - // TODO remove terminate_notification in 3.0 - if v, ok := d.GetOk("terminate_notification"); ok { - virtualMachineProfile.ScheduledEventsProfile = ExpandVirtualMachineScaleSetScheduledEventsProfile(v.([]interface{})) + if !features.FourPointOhBeta() { + if v, ok := d.GetOk("terminate_notification"); ok { + virtualMachineProfile.ScheduledEventsProfile = ExpandVirtualMachineScaleSetScheduledEventsProfile(v.([]interface{})) + } } if v, ok := d.GetOk("termination_notification"); ok { @@ -842,10 +587,11 @@ func resourceLinuxVirtualMachineScaleSetUpdate(d *pluginsdk.ResourceData, meta i } } - // TODO remove terminate_notification in 3.0 - if d.HasChange("terminate_notification") { - notificationRaw := d.Get("terminate_notification").([]interface{}) - updateProps.VirtualMachineProfile.ScheduledEventsProfile = ExpandVirtualMachineScaleSetScheduledEventsProfile(notificationRaw) + if !features.FourPointOhBeta() { + if d.HasChange("terminate_notification") { + notificationRaw := d.Get("terminate_notification").([]interface{}) + updateProps.VirtualMachineProfile.ScheduledEventsProfile = ExpandVirtualMachineScaleSetScheduledEventsProfile(notificationRaw) + } } if d.HasChange("termination_notification") { @@ -1098,10 +844,11 @@ func resourceLinuxVirtualMachineScaleSetRead(d *pluginsdk.ResourceData, meta int d.Set("health_probe_id", healthProbeId) } - // TODO remove terminate_notification in 3.0 - if scheduleProfile := profile.ScheduledEventsProfile; scheduleProfile != nil { - if err := d.Set("terminate_notification", FlattenVirtualMachineScaleSetScheduledEventsProfile(scheduleProfile)); err != nil { - return fmt.Errorf("setting `terminate_notification`: %+v", err) + if !features.FourPointOhBeta() { + if scheduleProfile := profile.ScheduledEventsProfile; scheduleProfile != nil { + if err := d.Set("terminate_notification", FlattenVirtualMachineScaleSetScheduledEventsProfile(scheduleProfile)); err != nil { + return fmt.Errorf("setting `terminate_notification`: %+v", err) + } } } @@ -1231,3 +978,267 @@ func resourceLinuxVirtualMachineScaleSetDelete(d *pluginsdk.ResourceData, meta i return nil } + +func resourceLinuxVirtualMachineScaleSetSchema() map[string]*pluginsdk.Schema { + out := map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.VirtualMachineName, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "location": azure.SchemaLocation(), + + // Required + "admin_username": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "network_interface": VirtualMachineScaleSetNetworkInterfaceSchema(), + + "os_disk": VirtualMachineScaleSetOSDiskSchema(), + + "instances": { + Type: pluginsdk.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(0), + }, + + "sku": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + // Optional + "additional_capabilities": VirtualMachineScaleSetAdditionalCapabilitiesSchema(), + + "admin_password": { + Type: pluginsdk.TypeString, + Optional: true, + ForceNew: true, + Sensitive: true, + DiffSuppressFunc: adminPasswordDiffSuppressFunc, + }, + + "admin_ssh_key": SSHKeysSchema(false), + + "automatic_os_upgrade_policy": VirtualMachineScaleSetAutomatedOSUpgradePolicySchema(), + + "automatic_instance_repair": VirtualMachineScaleSetAutomaticRepairsPolicySchema(), + + "boot_diagnostics": bootDiagnosticsSchema(), + + "computer_name_prefix": { + Type: pluginsdk.TypeString, + Optional: true, + + // Computed since we reuse the VM name if one's not specified + Computed: true, + ForceNew: true, + + ValidateFunc: validate.LinuxComputerNamePrefix, + }, + + "custom_data": base64.OptionalSchema(false), + + "data_disk": VirtualMachineScaleSetDataDiskSchema(), + + "disable_password_authentication": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: true, + }, + + "do_not_run_extensions_on_overprovisioned_machines": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + "edge_zone": commonschema.EdgeZoneOptionalForceNew(), + + "encryption_at_host_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + }, + + "eviction_policy": { + // only applicable when `priority` is set to `Spot` + Type: pluginsdk.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + string(compute.VirtualMachineEvictionPolicyTypesDeallocate), + string(compute.VirtualMachineEvictionPolicyTypesDelete), + }, false), + }, + + "extension": VirtualMachineScaleSetExtensionsSchema(), + + "extensions_time_budget": { + Type: pluginsdk.TypeString, + Optional: true, + Default: "PT1H30M", + ValidateFunc: azValidate.ISO8601DurationBetween("PT15M", "PT2H"), + }, + + "health_probe_id": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: azure.ValidateResourceID, + }, + + "identity": commonschema.SystemAssignedUserAssignedIdentityOptional(), + + "max_bid_price": { + Type: pluginsdk.TypeFloat, + Optional: true, + Default: -1, + ValidateFunc: validate.SpotMaxPrice, + }, + + "overprovision": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: true, + }, + + "plan": planSchema(), + + "platform_fault_domain_count": { + Type: pluginsdk.TypeInt, + Optional: true, + ForceNew: true, + Computed: true, + }, + + "priority": { + Type: pluginsdk.TypeString, + Optional: true, + ForceNew: true, + Default: string(compute.VirtualMachinePriorityTypesRegular), + ValidateFunc: validation.StringInSlice([]string{ + string(compute.VirtualMachinePriorityTypesRegular), + string(compute.VirtualMachinePriorityTypesSpot), + }, false), + }, + + "provision_vm_agent": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: true, + ForceNew: true, + }, + + "proximity_placement_group_id": { + Type: pluginsdk.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validate.ProximityPlacementGroupID, + // the Compute API is broken and returns the Resource Group name in UPPERCASE :shrug:, github issue: https://github.com/Azure/azure-rest-api-specs/issues/10016 + DiffSuppressFunc: suppress.CaseDifference, + }, + + "rolling_upgrade_policy": VirtualMachineScaleSetRollingUpgradePolicySchema(), + + "secret": linuxSecretSchema(), + + "secure_boot_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + ForceNew: true, + }, + + "single_placement_group": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: true, + }, + + "source_image_id": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.Any( + validate.ImageID, + validate.SharedImageID, + validate.SharedImageVersionID, + ), + }, + + "source_image_reference": sourceImageReferenceSchema(false), + + "tags": tags.Schema(), + + "upgrade_mode": { + Type: pluginsdk.TypeString, + Optional: true, + ForceNew: true, + Default: string(compute.UpgradeModeManual), + ValidateFunc: validation.StringInSlice([]string{ + string(compute.UpgradeModeAutomatic), + string(compute.UpgradeModeManual), + string(compute.UpgradeModeRolling), + }, false), + }, + + "user_data": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsBase64, + }, + + "vtpm_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + ForceNew: true, + }, + + "zone_balance": { + Type: pluginsdk.TypeBool, + Optional: true, + ForceNew: true, + Default: false, + }, + + "scale_in_policy": { + Type: pluginsdk.TypeString, + Optional: true, + Default: string(compute.VirtualMachineScaleSetScaleInRulesDefault), + ValidateFunc: validation.StringInSlice([]string{ + string(compute.VirtualMachineScaleSetScaleInRulesDefault), + string(compute.VirtualMachineScaleSetScaleInRulesNewestVM), + string(compute.VirtualMachineScaleSetScaleInRulesOldestVM), + }, false), + }, + + "termination_notification": VirtualMachineScaleSetTerminationNotificationSchema(), + + "zones": func() *schema.Schema { + if !features.ThreePointOhBeta() { + return azure.SchemaZones() + } + + return commonschema.ZonesMultipleOptionalForceNew() + }(), + + // Computed + "unique_id": { + Type: pluginsdk.TypeString, + Computed: true, + }, + } + + if !features.FourPointOhBeta() { + out["terminate_notification"] = VirtualMachineScaleSetTerminateNotificationSchema() + + } + + return out +} \ No newline at end of file diff --git a/internal/services/compute/virtual_machine_scale_set.go b/internal/services/compute/virtual_machine_scale_set.go index 0a49fb8af3294..57856231f612b 100644 --- a/internal/services/compute/virtual_machine_scale_set.go +++ b/internal/services/compute/virtual_machine_scale_set.go @@ -1398,14 +1398,14 @@ func FlattenVirtualMachineScaleSetRollingUpgradePolicy(input *compute.RollingUpg } } -// TODO remove VirtualMachineScaleSetTerminateNotificationSchema in 3.0 +// TODO remove VirtualMachineScaleSetTerminateNotificationSchema in 4.0 func VirtualMachineScaleSetTerminateNotificationSchema() *pluginsdk.Schema { return &pluginsdk.Schema{ Type: pluginsdk.TypeList, Optional: true, Computed: true, MaxItems: 1, - Deprecated: "`terminate_notification` has been renamed to `termination_notification` and will be removed in 3.0.", + Deprecated: "`terminate_notification` has been renamed to `termination_notification` and will be removed in 4.0.", Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ "enabled": { @@ -1444,7 +1444,7 @@ func VirtualMachineScaleSetTerminationNotificationSchema() *pluginsdk.Schema { }, }, }, - // TODO remove ConflictsWith in 3.0 + // TODO remove ConflictsWith in 4.0 ConflictsWith: []string{"terminate_notification"}, } } diff --git a/internal/services/compute/windows_virtual_machine_scale_set_other_resource_test.go b/internal/services/compute/windows_virtual_machine_scale_set_other_resource_test.go index 2a677cdbd0338..d3dc961243362 100644 --- a/internal/services/compute/windows_virtual_machine_scale_set_other_resource_test.go +++ b/internal/services/compute/windows_virtual_machine_scale_set_other_resource_test.go @@ -571,7 +571,7 @@ func TestAccWindowsVirtualMachineScaleSet_otherTerminationNotification(t *testin }) } -// TODO remove TestAccWindowsVirtualMachineScaleSet_otherTerminationNotificationMigration in 3.0 +// TODO remove TestAccWindowsVirtualMachineScaleSet_otherTerminationNotificationMigration in 4.0 func TestAccWindowsVirtualMachineScaleSet_otherTerminationNotificationMigration(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_windows_virtual_machine_scale_set", "test") r := WindowsVirtualMachineScaleSetResource{} @@ -2371,7 +2371,7 @@ resource "azurerm_windows_virtual_machine_scale_set" "test" { `, r.template(data)) } -// TODO remove otherTerminateNotification in 3.0 +// TODO remove otherTerminateNotification in 4.0 func (r WindowsVirtualMachineScaleSetResource) otherTerminateNotification(data acceptance.TestData, enabled bool) string { return fmt.Sprintf(` %s diff --git a/internal/services/compute/windows_virtual_machine_scale_set_resource.go b/internal/services/compute/windows_virtual_machine_scale_set_resource.go index 3ea50c3c0465b..ce4720bb872f2 100644 --- a/internal/services/compute/windows_virtual_machine_scale_set_resource.go +++ b/internal/services/compute/windows_virtual_machine_scale_set_resource.go @@ -51,286 +51,7 @@ func resourceWindowsVirtualMachineScaleSet() *pluginsdk.Resource { // TODO: exposing requireGuestProvisionSignal once it's available // https://github.com/Azure/azure-rest-api-specs/pull/7246 - Schema: map[string]*pluginsdk.Schema{ - "name": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: computeValidate.VirtualMachineName, - }, - - "resource_group_name": azure.SchemaResourceGroupName(), - - "location": azure.SchemaLocation(), - - // Required - "admin_username": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - "admin_password": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - Sensitive: true, - DiffSuppressFunc: adminPasswordDiffSuppressFunc, - ValidateFunc: validation.StringIsNotEmpty, - }, - - "network_interface": VirtualMachineScaleSetNetworkInterfaceSchema(), - - "os_disk": VirtualMachineScaleSetOSDiskSchema(), - - "instances": { - Type: pluginsdk.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(0), - }, - - "sku": { - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - // Optional - "additional_capabilities": VirtualMachineScaleSetAdditionalCapabilitiesSchema(), - - "additional_unattend_content": additionalUnattendContentSchema(), - - "automatic_os_upgrade_policy": VirtualMachineScaleSetAutomatedOSUpgradePolicySchema(), - - "automatic_instance_repair": VirtualMachineScaleSetAutomaticRepairsPolicySchema(), - - "boot_diagnostics": bootDiagnosticsSchema(), - - "computer_name_prefix": { - Type: pluginsdk.TypeString, - Optional: true, - - // Computed since we reuse the VM name if one's not specified - Computed: true, - ForceNew: true, - - ValidateFunc: computeValidate.WindowsComputerNamePrefix, - }, - - "custom_data": base64.OptionalSchema(false), - - "data_disk": VirtualMachineScaleSetDataDiskSchema(), - - "do_not_run_extensions_on_overprovisioned_machines": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: false, - }, - - "edge_zone": commonschema.EdgeZoneOptionalForceNew(), - - // TODO 4.0: change this from enable_* to *_enabled - "enable_automatic_updates": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: true, - }, - - "encryption_at_host_enabled": { - Type: pluginsdk.TypeBool, - Optional: true, - }, - - "eviction_policy": { - // only applicable when `priority` is set to `Spot` - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - string(compute.VirtualMachineEvictionPolicyTypesDeallocate), - string(compute.VirtualMachineEvictionPolicyTypesDelete), - }, false), - }, - - "extension": VirtualMachineScaleSetExtensionsSchema(), - - "extensions_time_budget": { - Type: pluginsdk.TypeString, - Optional: true, - Default: "PT1H30M", - ValidateFunc: validate.ISO8601DurationBetween("PT15M", "PT2H"), - }, - - "health_probe_id": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: azure.ValidateResourceID, - }, - - "identity": commonschema.SystemAssignedUserAssignedIdentityOptional(), - - "license_type": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{ - "None", - "Windows_Client", - "Windows_Server", - }, false), - DiffSuppressFunc: func(_, old, new string, _ *pluginsdk.ResourceData) bool { - if old == "None" && new == "" || old == "" && new == "None" { - return true - } - - return false - }, - }, - - "max_bid_price": { - Type: pluginsdk.TypeFloat, - Optional: true, - Default: -1, - ValidateFunc: computeValidate.SpotMaxPrice, - }, - - "overprovision": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: true, - }, - - "plan": planSchema(), - - "platform_fault_domain_count": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - Computed: true, - }, - - "priority": { - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - Default: string(compute.VirtualMachinePriorityTypesRegular), - ValidateFunc: validation.StringInSlice([]string{ - string(compute.VirtualMachinePriorityTypesRegular), - string(compute.VirtualMachinePriorityTypesSpot), - }, false), - }, - - "provision_vm_agent": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: true, - ForceNew: true, - }, - - "proximity_placement_group_id": { - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: azure.ValidateResourceID, - // the Compute API is broken and returns the Resource Group name in UPPERCASE :shrug:, github issue: https://github.com/Azure/azure-rest-api-specs/issues/10016 - DiffSuppressFunc: suppress.CaseDifference, - }, - - "rolling_upgrade_policy": VirtualMachineScaleSetRollingUpgradePolicySchema(), - - "secret": windowsSecretSchema(), - - "secure_boot_enabled": { - Type: pluginsdk.TypeBool, - Optional: true, - ForceNew: true, - }, - - "single_placement_group": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: true, - }, - - "source_image_id": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: azure.ValidateResourceID, - }, - - "source_image_reference": sourceImageReferenceSchema(false), - - "tags": tags.Schema(), - - "timezone": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: computeValidate.VirtualMachineTimeZone(), - }, - - "upgrade_mode": { - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - Default: string(compute.UpgradeModeManual), - ValidateFunc: validation.StringInSlice([]string{ - string(compute.UpgradeModeAutomatic), - string(compute.UpgradeModeManual), - string(compute.UpgradeModeRolling), - }, false), - }, - - "user_data": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: validation.StringIsBase64, - }, - - "vtpm_enabled": { - Type: pluginsdk.TypeBool, - Optional: true, - ForceNew: true, - }, - - "winrm_listener": winRmListenerSchema(), - - "zone_balance": { - Type: pluginsdk.TypeBool, - Optional: true, - ForceNew: true, - Default: false, - }, - - "scale_in_policy": { - Type: pluginsdk.TypeString, - Optional: true, - Default: string(compute.VirtualMachineScaleSetScaleInRulesDefault), - ValidateFunc: validation.StringInSlice([]string{ - string(compute.VirtualMachineScaleSetScaleInRulesDefault), - string(compute.VirtualMachineScaleSetScaleInRulesNewestVM), - string(compute.VirtualMachineScaleSetScaleInRulesOldestVM), - }, false), - }, - - // TODO remove terminate_notification in 3.0 - "terminate_notification": VirtualMachineScaleSetTerminateNotificationSchema(), - - "termination_notification": VirtualMachineScaleSetTerminationNotificationSchema(), - - "zones": func() *schema.Schema { - if !features.ThreePointOhBeta() { - return azure.SchemaZones() - } - - return commonschema.ZonesMultipleOptionalForceNew() - }(), - - // Computed - "unique_id": { - Type: pluginsdk.TypeString, - Computed: true, - }, - }, + Schema: resourceWindowsVirtualMachineScaleSetSchema(), } } @@ -566,9 +287,10 @@ func resourceWindowsVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData, meta virtualMachineProfile.OsProfile.WindowsConfiguration.TimeZone = utils.String(v.(string)) } - // TODO remove terminate_notification in 3.0 - if v, ok := d.GetOk("terminate_notification"); ok { - virtualMachineProfile.ScheduledEventsProfile = ExpandVirtualMachineScaleSetScheduledEventsProfile(v.([]interface{})) + if !features.FourPointOhBeta() { + if v, ok := d.GetOk("terminate_notification"); ok { + virtualMachineProfile.ScheduledEventsProfile = ExpandVirtualMachineScaleSetScheduledEventsProfile(v.([]interface{})) + } } if v, ok := d.GetOk("termination_notification"); ok { @@ -881,10 +603,11 @@ func resourceWindowsVirtualMachineScaleSetUpdate(d *pluginsdk.ResourceData, meta } } - // TODO remove terminate_notification in 3.0 - if d.HasChange("terminate_notification") { - notificationRaw := d.Get("terminate_notification").([]interface{}) - updateProps.VirtualMachineProfile.ScheduledEventsProfile = ExpandVirtualMachineScaleSetScheduledEventsProfile(notificationRaw) + if !features.FourPointOhBeta() { + if d.HasChange("terminate_notification") { + notificationRaw := d.Get("terminate_notification").([]interface{}) + updateProps.VirtualMachineProfile.ScheduledEventsProfile = ExpandVirtualMachineScaleSetScheduledEventsProfile(notificationRaw) + } } if d.HasChange("termination_notification") { @@ -1178,10 +901,11 @@ func resourceWindowsVirtualMachineScaleSetRead(d *pluginsdk.ResourceData, meta i d.Set("health_probe_id", healthProbeId) } - // TODO remove terminate_notification in 3.0 - if scheduleProfile := profile.ScheduledEventsProfile; scheduleProfile != nil { - if err := d.Set("terminate_notification", FlattenVirtualMachineScaleSetScheduledEventsProfile(scheduleProfile)); err != nil { - return fmt.Errorf("setting `terminate_notification`: %+v", err) + if !features.FourPointOhBeta() { + if scheduleProfile := profile.ScheduledEventsProfile; scheduleProfile != nil { + if err := d.Set("terminate_notification", FlattenVirtualMachineScaleSetScheduledEventsProfile(scheduleProfile)); err != nil { + return fmt.Errorf("setting `terminate_notification`: %+v", err) + } } } @@ -1296,3 +1020,289 @@ func resourceWindowsVirtualMachineScaleSetDelete(d *pluginsdk.ResourceData, meta return nil } + +func resourceWindowsVirtualMachineScaleSetSchema() map[string]*pluginsdk.Schema { + out := map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: computeValidate.VirtualMachineName, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "location": azure.SchemaLocation(), + + // Required + "admin_username": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "admin_password": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + Sensitive: true, + DiffSuppressFunc: adminPasswordDiffSuppressFunc, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "network_interface": VirtualMachineScaleSetNetworkInterfaceSchema(), + + "os_disk": VirtualMachineScaleSetOSDiskSchema(), + + "instances": { + Type: pluginsdk.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(0), + }, + + "sku": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + // Optional + "additional_capabilities": VirtualMachineScaleSetAdditionalCapabilitiesSchema(), + + "additional_unattend_content": additionalUnattendContentSchema(), + + "automatic_os_upgrade_policy": VirtualMachineScaleSetAutomatedOSUpgradePolicySchema(), + + "automatic_instance_repair": VirtualMachineScaleSetAutomaticRepairsPolicySchema(), + + "boot_diagnostics": bootDiagnosticsSchema(), + + "computer_name_prefix": { + Type: pluginsdk.TypeString, + Optional: true, + + // Computed since we reuse the VM name if one's not specified + Computed: true, + ForceNew: true, + + ValidateFunc: computeValidate.WindowsComputerNamePrefix, + }, + + "custom_data": base64.OptionalSchema(false), + + "data_disk": VirtualMachineScaleSetDataDiskSchema(), + + "do_not_run_extensions_on_overprovisioned_machines": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + "edge_zone": commonschema.EdgeZoneOptionalForceNew(), + + // TODO 4.0: change this from enable_* to *_enabled + "enable_automatic_updates": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: true, + }, + + "encryption_at_host_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + }, + + "eviction_policy": { + // only applicable when `priority` is set to `Spot` + Type: pluginsdk.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + string(compute.VirtualMachineEvictionPolicyTypesDeallocate), + string(compute.VirtualMachineEvictionPolicyTypesDelete), + }, false), + }, + + "extension": VirtualMachineScaleSetExtensionsSchema(), + + "extensions_time_budget": { + Type: pluginsdk.TypeString, + Optional: true, + Default: "PT1H30M", + ValidateFunc: validate.ISO8601DurationBetween("PT15M", "PT2H"), + }, + + "health_probe_id": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: azure.ValidateResourceID, + }, + + "identity": commonschema.SystemAssignedUserAssignedIdentityOptional(), + + "license_type": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + "None", + "Windows_Client", + "Windows_Server", + }, false), + DiffSuppressFunc: func(_, old, new string, _ *pluginsdk.ResourceData) bool { + if old == "None" && new == "" || old == "" && new == "None" { + return true + } + + return false + }, + }, + + "max_bid_price": { + Type: pluginsdk.TypeFloat, + Optional: true, + Default: -1, + ValidateFunc: computeValidate.SpotMaxPrice, + }, + + "overprovision": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: true, + }, + + "plan": planSchema(), + + "platform_fault_domain_count": { + Type: pluginsdk.TypeInt, + Optional: true, + ForceNew: true, + Computed: true, + }, + + "priority": { + Type: pluginsdk.TypeString, + Optional: true, + ForceNew: true, + Default: string(compute.VirtualMachinePriorityTypesRegular), + ValidateFunc: validation.StringInSlice([]string{ + string(compute.VirtualMachinePriorityTypesRegular), + string(compute.VirtualMachinePriorityTypesSpot), + }, false), + }, + + "provision_vm_agent": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: true, + ForceNew: true, + }, + + "proximity_placement_group_id": { + Type: pluginsdk.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: azure.ValidateResourceID, + // the Compute API is broken and returns the Resource Group name in UPPERCASE :shrug:, github issue: https://github.com/Azure/azure-rest-api-specs/issues/10016 + DiffSuppressFunc: suppress.CaseDifference, + }, + + "rolling_upgrade_policy": VirtualMachineScaleSetRollingUpgradePolicySchema(), + + "secret": windowsSecretSchema(), + + "secure_boot_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + ForceNew: true, + }, + + "single_placement_group": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: true, + }, + + "source_image_id": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: azure.ValidateResourceID, + }, + + "source_image_reference": sourceImageReferenceSchema(false), + + "tags": tags.Schema(), + + "timezone": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: computeValidate.VirtualMachineTimeZone(), + }, + + "upgrade_mode": { + Type: pluginsdk.TypeString, + Optional: true, + ForceNew: true, + Default: string(compute.UpgradeModeManual), + ValidateFunc: validation.StringInSlice([]string{ + string(compute.UpgradeModeAutomatic), + string(compute.UpgradeModeManual), + string(compute.UpgradeModeRolling), + }, false), + }, + + "user_data": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsBase64, + }, + + "vtpm_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + ForceNew: true, + }, + + "winrm_listener": winRmListenerSchema(), + + "zone_balance": { + Type: pluginsdk.TypeBool, + Optional: true, + ForceNew: true, + Default: false, + }, + + "scale_in_policy": { + Type: pluginsdk.TypeString, + Optional: true, + Default: string(compute.VirtualMachineScaleSetScaleInRulesDefault), + ValidateFunc: validation.StringInSlice([]string{ + string(compute.VirtualMachineScaleSetScaleInRulesDefault), + string(compute.VirtualMachineScaleSetScaleInRulesNewestVM), + string(compute.VirtualMachineScaleSetScaleInRulesOldestVM), + }, false), + }, + + "termination_notification": VirtualMachineScaleSetTerminationNotificationSchema(), + + "zones": func() *schema.Schema { + if !features.ThreePointOhBeta() { + return azure.SchemaZones() + } + + return commonschema.ZonesMultipleOptionalForceNew() + }(), + + // Computed + "unique_id": { + Type: pluginsdk.TypeString, + Computed: true, + }, + } + + if !features.FourPointOhBeta() { + out["terminate_notification"] = VirtualMachineScaleSetTerminateNotificationSchema() + } + + return out +} \ No newline at end of file diff --git a/website/docs/r/linux_virtual_machine_scale_set.html.markdown b/website/docs/r/linux_virtual_machine_scale_set.html.markdown index c20a9812f2552..8751cc455dce2 100644 --- a/website/docs/r/linux_virtual_machine_scale_set.html.markdown +++ b/website/docs/r/linux_virtual_machine_scale_set.html.markdown @@ -202,7 +202,7 @@ The following arguments are supported: * `terminate_notification` - (Optional) A `terminate_notification` block as defined below. -~> **Note:** This property has been deprecated in favour of the `termination_notification` property and will be removed in version 3.0 of the provider. +~> **Note:** This property has been deprecated in favour of the `termination_notification` property and will be removed in version 4.0 of the provider. * `termination_notification` - (Optional) A `termination_notification` block as defined below. diff --git a/website/docs/r/windows_virtual_machine_scale_set.html.markdown b/website/docs/r/windows_virtual_machine_scale_set.html.markdown index 10071a219f31d..3239f5e3c55d1 100644 --- a/website/docs/r/windows_virtual_machine_scale_set.html.markdown +++ b/website/docs/r/windows_virtual_machine_scale_set.html.markdown @@ -192,7 +192,7 @@ The following arguments are supported: * `terminate_notification` - (Optional) A `terminate_notification` block as defined below. -~> **Note:** This property has been deprecated in favour of the `termination_notification` property and will be removed in version 3.0 of the provider. +~> **Note:** This property has been deprecated in favour of the `termination_notification` property and will be removed in version 4.0 of the provider. * `termination_notification` - (Optional) A `termination_notification` block as defined below.