diff --git a/internal/services/compute/encryption_settings.go b/internal/services/compute/encryption_settings.go index 57e75301a9ac..e3c49a1260a5 100644 --- a/internal/services/compute/encryption_settings.go +++ b/internal/services/compute/encryption_settings.go @@ -6,70 +6,11 @@ package compute import ( "github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-02/snapshots" "github.com/hashicorp/go-azure-sdk/resource-manager/compute/2023-04-02/disks" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) func encryptionSettingsSchema() *pluginsdk.Schema { - if !features.FourPointOhBeta() { - return &pluginsdk.Schema{ - Type: pluginsdk.TypeList, - Optional: true, - MaxItems: 1, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "enabled": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: true, - - // Azure can change enabled from false to true, but not the other way around, so - // to keep idempotency, we'll conservatively set this to ForceNew=true - ForceNew: true, - Deprecated: "Deprecated, Azure Disk Encryption is now configured directly by `disk_encryption_key` and `key_encryption_key`. To disable Azure Disk Encryption, please remove `encryption_settings` block. To enabled, specify a `encryption_settings` block`", - }, - "disk_encryption_key": { - Type: pluginsdk.TypeList, - Optional: true, - MaxItems: 1, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "secret_url": { - Type: pluginsdk.TypeString, - Required: true, - }, - - "source_vault_id": { - Type: pluginsdk.TypeString, - Required: true, - }, - }, - }, - }, - "key_encryption_key": { - Type: pluginsdk.TypeList, - Optional: true, - MaxItems: 1, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "key_url": { - Type: pluginsdk.TypeString, - Required: true, - }, - - "source_vault_id": { - Type: pluginsdk.TypeString, - Required: true, - }, - }, - }, - }, - }, - }, - } - } - return &pluginsdk.Schema{ Type: pluginsdk.TypeList, Optional: true, @@ -127,10 +68,6 @@ func expandSnapshotDiskEncryptionSettings(settingsList []interface{}) *snapshots Enabled: true, } - if !features.FourPointOhBeta() { - config.Enabled = settings["enabled"].(bool) - } - var diskEncryptionKey *snapshots.KeyVaultAndSecretReference if v := settings["disk_encryption_key"].([]interface{}); len(v) > 0 { dek := v[0].(map[string]interface{}) @@ -216,16 +153,6 @@ func flattenSnapshotDiskEncryptionSettings(encryptionSettings *snapshots.Encrypt } if len(diskEncryptionKeys) > 0 { - if !features.FourPointOhBeta() { - return []interface{}{ - map[string]interface{}{ - "enabled": true, - "disk_encryption_key": diskEncryptionKeys, - "key_encryption_key": keyEncryptionKeys, - }, - } - } - return []interface{}{ map[string]interface{}{ "disk_encryption_key": diskEncryptionKeys, @@ -247,10 +174,6 @@ func expandManagedDiskEncryptionSettings(settingsList []interface{}) *disks.Encr Enabled: true, } - if !features.FourPointOhBeta() { - config.Enabled = settings["enabled"].(bool) - } - var diskEncryptionKey *disks.KeyVaultAndSecretReference if v := settings["disk_encryption_key"].([]interface{}); len(v) > 0 { dek := v[0].(map[string]interface{}) @@ -336,16 +259,6 @@ func flattenManagedDiskEncryptionSettings(encryptionSettings *disks.EncryptionSe } if len(diskEncryptionKeys) > 0 { - if !features.FourPointOhBeta() { - return []interface{}{ - map[string]interface{}{ - "enabled": true, - "disk_encryption_key": diskEncryptionKeys, - "key_encryption_key": keyEncryptionKeys, - }, - } - } - return []interface{}{ map[string]interface{}{ "disk_encryption_key": diskEncryptionKeys, diff --git a/internal/services/compute/image_resource.go b/internal/services/compute/image_resource.go index dd65c7cac171..400cf28f4e53 100644 --- a/internal/services/compute/image_resource.go +++ b/internal/services/compute/image_resource.go @@ -16,7 +16,6 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-01/images" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" @@ -26,7 +25,7 @@ import ( ) func resourceImage() *pluginsdk.Resource { - resource := &pluginsdk.Resource{ + return &pluginsdk.Resource{ Create: resourceImageCreateUpdate, Read: resourceImageRead, Update: resourceImageCreateUpdate, @@ -219,13 +218,6 @@ func resourceImage() *pluginsdk.Resource { "tags": commonschema.Tags(), }, } - - if !features.FourPointOhBeta() { - delete(resource.Schema["os_disk"].Elem.(*pluginsdk.Resource).Schema, "storage_type") - delete(resource.Schema["data_disk"].Elem.(*pluginsdk.Resource).Schema, "storage_type") - } - - return resource } func resourceImageCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { @@ -403,9 +395,8 @@ func expandImageOSDisk(input []interface{}) *images.ImageOSDisk { } } - if features.FourPointOhBeta() { - out.StorageAccountType = pointer.To(images.StorageAccountTypes(config["storage_type"].(string))) - } + out.StorageAccountType = pointer.To(images.StorageAccountTypes(config["storage_type"].(string))) + return out } @@ -443,9 +434,7 @@ func expandImageDataDisks(disks []interface{}) *[]images.ImageDataDisk { } } - if features.FourPointOhBeta() { - item.StorageAccountType = pointer.To(images.StorageAccountTypes(config["storage_type"].(string))) - } + item.StorageAccountType = pointer.To(images.StorageAccountTypes(config["storage_type"].(string))) output = append(output, item) } @@ -490,13 +479,11 @@ func flattenImageOSDisk(input *images.ImageStorageProfile) []interface{} { "disk_encryption_set_id": diskEncryptionSetId, } - if features.FourPointOhBeta() { - storageType := "" - if v.StorageAccountType != nil { - storageType = string(*v.StorageAccountType) - } - properties["storage_type"] = storageType + storageType := "" + if v.StorageAccountType != nil { + storageType = string(*v.StorageAccountType) } + properties["storage_type"] = storageType output = append(output, properties) } @@ -542,13 +529,11 @@ func flattenImageDataDisks(input *images.ImageStorageProfile) []interface{} { "disk_encryption_set_id": diskEncryptionSetId, } - if features.FourPointOhBeta() { - storageType := "" - if disk.StorageAccountType != nil { - storageType = string(*disk.StorageAccountType) - } - properties["storage_type"] = storageType + storageType := "" + if disk.StorageAccountType != nil { + storageType = string(*disk.StorageAccountType) } + properties["storage_type"] = storageType output = append(output, properties) } diff --git a/internal/services/compute/image_resource_test.go b/internal/services/compute/image_resource_test.go index 697b04ef8283..fbb8b775439d 100644 --- a/internal/services/compute/image_resource_test.go +++ b/internal/services/compute/image_resource_test.go @@ -22,7 +22,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/ssh" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -524,16 +523,6 @@ func (r ImageResource) standaloneImageProvision(data acceptance.TestData, hyperV caching = "None" storage_type = "StandardSSD_LRS" }` - if !features.FourPointOhBeta() { - osDisk = ` - os_disk { - os_type = "Linux" - os_state = "Generalized" - blob_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd" - size_gb = 30 - caching = "None" - }` - } template := r.setupUnmanagedDisks(data) @@ -569,16 +558,6 @@ func (r ImageResource) standaloneImageRequiresImport(data acceptance.TestData) s caching = "None" storage_type = "StandardSSD_LRS" }` - if !features.FourPointOhBeta() { - osDisk = ` - os_disk { - os_type = "Linux" - os_state = "Generalized" - blob_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd" - size_gb = 30 - caching = "None" - }` - } return fmt.Sprintf(` %[1]s @@ -610,16 +589,6 @@ func (r ImageResource) customImageFromVMWithUnmanagedDisksProvision(data accepta caching = "None" storage_type = "StandardSSD_LRS" }` - if !features.FourPointOhBeta() { - osDisk = ` - os_disk { - os_type = "Linux" - os_state = "Generalized" - blob_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd" - size_gb = 30 - caching = "None" - }` - } return fmt.Sprintf(` %[1]s @@ -764,16 +733,6 @@ func (r ImageResource) customImageFromVMSSWithUnmanagedDisksProvision(data accep caching = "None" storage_type = "StandardSSD_LRS" }` - if !features.FourPointOhBeta() { - osDisk = ` - os_disk { - os_type = "Linux" - os_state = "Generalized" - blob_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd" - size_gb = 30 - caching = "None" - }` - } return fmt.Sprintf(` %[1]s @@ -846,17 +805,6 @@ func (r ImageResource) standaloneImageEncrypt(data acceptance.TestData) string { disk_encryption_set_id = azurerm_disk_encryption_set.test.id storage_type = "StandardSSD_LRS" }` - if !features.FourPointOhBeta() { - osDisk = ` - os_disk { - os_type = "Linux" - os_state = "Generalized" - blob_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd" - size_gb = 30 - caching = "None" - disk_encryption_set_id = azurerm_disk_encryption_set.test.id - }` - } dataDisk := ` data_disk { @@ -866,15 +814,6 @@ func (r ImageResource) standaloneImageEncrypt(data acceptance.TestData) string { disk_encryption_set_id = azurerm_disk_encryption_set.test.id storage_type = "StandardSSD_LRS" }` - if !features.FourPointOhBeta() { - dataDisk = ` - data_disk { - blob_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd" - size_gb = 30 - caching = "None" - disk_encryption_set_id = azurerm_disk_encryption_set.test.id - }` - } return fmt.Sprintf(` %[1]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 9a66e6acd2e5..ea2abe43b721 100644 --- a/internal/services/compute/linux_virtual_machine_scale_set_resource.go +++ b/internal/services/compute/linux_virtual_machine_scale_set_resource.go @@ -26,7 +26,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" azValidate "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/base64" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" @@ -230,14 +229,6 @@ func resourceLinuxVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData, meta i }, } - if !features.FourPointOhBeta() { - if galleryApplications := expandVirtualMachineScaleSetGalleryApplications(d.Get("gallery_applications").([]interface{})); galleryApplications != nil { - virtualMachineProfile.ApplicationProfile = &virtualmachinescalesets.ApplicationProfile{ - GalleryApplications: galleryApplications, - } - } - } - if galleryApplications := expandVirtualMachineScaleSetGalleryApplication(d.Get("gallery_application").([]interface{})); galleryApplications != nil { virtualMachineProfile.ApplicationProfile = &virtualmachinescalesets.ApplicationProfile{ GalleryApplications: galleryApplications, @@ -268,13 +259,7 @@ func resourceLinuxVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData, meta i return fmt.Errorf("`extension_operations_enabled` cannot be set to `true` when `provision_vm_agent` is set to `false`") } - if !features.FourPointOhBeta() { - if !pluginsdk.IsExplicitlyNullInConfig(d, "extension_operations_enabled") { - virtualMachineProfile.OsProfile.AllowExtensionOperations = pointer.To(v) - } - } else { - virtualMachineProfile.OsProfile.AllowExtensionOperations = pointer.To(v) - } + virtualMachineProfile.OsProfile.AllowExtensionOperations = pointer.To(v) } if v, ok := d.GetOk("extensions_time_budget"); ok { @@ -382,12 +367,6 @@ func resourceLinuxVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData, meta i return fmt.Errorf("an `eviction_policy` must be specified when `priority` is set to `Spot`") } - if !features.FourPointOhBeta() { - if v, ok := d.GetOk("terminate_notification"); ok { - virtualMachineProfile.ScheduledEventsProfile = ExpandVirtualMachineScaleSetScheduledEventsProfile(v.([]interface{})) - } - } - if v, ok := d.GetOk("termination_notification"); ok { virtualMachineProfile.ScheduledEventsProfile = ExpandVirtualMachineScaleSetScheduledEventsProfile(v.([]interface{})) } @@ -427,19 +406,6 @@ func resourceLinuxVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData, meta i }, } - if !features.FourPointOhBeta() { - scaleInPolicy := &virtualmachinescalesets.ScaleInPolicy{ - Rules: &[]virtualmachinescalesets.VirtualMachineScaleSetScaleInRules{virtualmachinescalesets.VirtualMachineScaleSetScaleInRules(string(virtualmachinescalesets.VirtualMachineScaleSetScaleInRulesDefault))}, - ForceDeletion: pointer.To(false), - } - - if v, ok := d.GetOk("scale_in_policy"); ok { - scaleInPolicy.Rules = &[]virtualmachinescalesets.VirtualMachineScaleSetScaleInRules{virtualmachinescalesets.VirtualMachineScaleSetScaleInRules(v.(string))} - } - - props.Properties.ScaleInPolicy = scaleInPolicy - } - if v, ok := d.GetOk("scale_in"); ok { if v := ExpandVirtualMachineScaleSetScaleInPolicy(v.([]interface{})); v != nil { props.Properties.ScaleInPolicy = v @@ -724,24 +690,6 @@ func resourceLinuxVirtualMachineScaleSetUpdate(d *pluginsdk.ResourceData, meta i } } - if !features.FourPointOhBeta() { - if d.HasChange("scale_in_policy") { - updateScaleInPolicy := &virtualmachinescalesets.ScaleInPolicy{} - - if d.HasChange("scale_in_policy") { - scaleInPolicy := d.Get("scale_in_policy").(string) - updateScaleInPolicy.Rules = &[]virtualmachinescalesets.VirtualMachineScaleSetScaleInRules{virtualmachinescalesets.VirtualMachineScaleSetScaleInRules(scaleInPolicy)} - } - - updateProps.ScaleInPolicy = updateScaleInPolicy - } - - if d.HasChange("terminate_notification") { - notificationRaw := d.Get("terminate_notification").([]interface{}) - updateProps.VirtualMachineProfile.ScheduledEventsProfile = ExpandVirtualMachineScaleSetScheduledEventsProfile(notificationRaw) - } - } - if d.HasChange("termination_notification") { notificationRaw := d.Get("termination_notification").([]interface{}) updateProps.VirtualMachineProfile.ScheduledEventsProfile = ExpandVirtualMachineScaleSetScheduledEventsProfile(notificationRaw) @@ -937,17 +885,6 @@ func resourceLinuxVirtualMachineScaleSetRead(d *pluginsdk.ResourceData, meta int d.Set("zone_balance", props.ZoneBalance) d.Set("scale_in", FlattenVirtualMachineScaleSetScaleInPolicy(props.ScaleInPolicy)) - if !features.FourPointOhBeta() { - rule := string(virtualmachinescalesets.VirtualMachineScaleSetScaleInRulesDefault) - - if props.ScaleInPolicy != nil { - if rules := props.ScaleInPolicy.Rules; rules != nil && len(*rules) > 0 { - rule = string((*rules)[0]) - } - } - d.Set("scale_in_policy", rule) - } - if props.SpotRestorePolicy != nil { d.Set("spot_restore", FlattenVirtualMachineScaleSetSpotRestorePolicy(props.SpotRestorePolicy)) } @@ -974,10 +911,6 @@ func resourceLinuxVirtualMachineScaleSetRead(d *pluginsdk.ResourceData, meta int if profile.ApplicationProfile != nil && profile.ApplicationProfile.GalleryApplications != nil { d.Set("gallery_application", flattenVirtualMachineScaleSetGalleryApplication(profile.ApplicationProfile.GalleryApplications)) - - if !features.FourPointOhBeta() { - d.Set("gallery_applications", flattenVirtualMachineScaleSetGalleryApplications(profile.ApplicationProfile.GalleryApplications)) - } } // the service just return empty when this is not assigned when provisioned @@ -1056,14 +989,6 @@ func resourceLinuxVirtualMachineScaleSetRead(d *pluginsdk.ResourceData, meta int d.Set("health_probe_id", healthProbeId) } - 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) - } - } - } - if scheduleProfile := profile.ScheduledEventsProfile; scheduleProfile != nil { if err := d.Set("termination_notification", FlattenVirtualMachineScaleSetScheduledEventsProfile(scheduleProfile)); err != nil { return fmt.Errorf("setting `termination_notification`: %+v", err) @@ -1190,7 +1115,7 @@ func resourceLinuxVirtualMachineScaleSetDelete(d *pluginsdk.ResourceData, meta i } func resourceLinuxVirtualMachineScaleSetSchema() map[string]*pluginsdk.Schema { - resourceSchema := map[string]*pluginsdk.Schema{ + return map[string]*pluginsdk.Schema{ "name": { Type: pluginsdk.TypeString, Required: true, @@ -1304,13 +1229,7 @@ func resourceLinuxVirtualMachineScaleSetSchema() map[string]*pluginsdk.Schema { "extension_operations_enabled": { Type: pluginsdk.TypeBool, Optional: true, - Default: func() interface{} { - if !features.FourPointOhBeta() { - return nil - } - return true - }(), - Computed: !features.FourPointOhBeta(), + Default: true, ForceNew: true, }, @@ -1478,24 +1397,4 @@ func resourceLinuxVirtualMachineScaleSetSchema() map[string]*pluginsdk.Schema { Computed: true, }, } - - if !features.FourPointOhBeta() { - resourceSchema["gallery_applications"] = VirtualMachineScaleSetGalleryApplicationsSchema() - resourceSchema["terminate_notification"] = VirtualMachineScaleSetTerminateNotificationSchema() - - resourceSchema["scale_in_policy"] = &schema.Schema{ - Type: pluginsdk.TypeString, - Optional: true, - Computed: !features.FourPointOhBeta(), - ValidateFunc: validation.StringInSlice([]string{ - string(virtualmachinescalesets.VirtualMachineScaleSetScaleInRulesDefault), - string(virtualmachinescalesets.VirtualMachineScaleSetScaleInRulesNewestVM), - string(virtualmachinescalesets.VirtualMachineScaleSetScaleInRulesOldestVM), - }, false), - Deprecated: "`scale_in_policy` will be removed in favour of the `scale_in` code block in version 4.0 of the AzureRM Provider.", - ConflictsWith: []string{"scale_in"}, - } - } - - return resourceSchema } diff --git a/internal/services/compute/linux_virtual_machine_scale_set_resource_other_test.go b/internal/services/compute/linux_virtual_machine_scale_set_resource_other_test.go index b6d982321d93..0b10c5d690a1 100644 --- a/internal/services/compute/linux_virtual_machine_scale_set_resource_other_test.go +++ b/internal/services/compute/linux_virtual_machine_scale_set_resource_other_test.go @@ -16,7 +16,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" ) func TestAccLinuxVirtualMachineScaleSet_otherBootDiagnostics(t *testing.T) { @@ -432,26 +431,6 @@ func TestAccLinuxVirtualMachineScaleSet_otherVMAgentDisabledWithExtensionDisable }) } -func TestAccLinuxVirtualMachineScaleSet_otherScaleInPolicy(t *testing.T) { - if features.FourPointOhBeta() { - t.Skipf("Skipped the 'scale_in_policy' property has been deprecated in the 4.0 provider.") - } - - data := acceptance.BuildTestData(t, "azurerm_linux_virtual_machine_scale_set", "test") - r := LinuxVirtualMachineScaleSetResource{} - - data.ResourceTest(t, r, []acceptance.TestStep{ - { - Config: r.otherScaleInPolicy(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("scale_in_policy").HasValue("Default"), - ), - }, - data.ImportStep("admin_password"), - }) -} - func TestAccLinuxVirtualMachineScaleSet_otherScaleIn(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_linux_virtual_machine_scale_set", "test") r := LinuxVirtualMachineScaleSetResource{} @@ -514,38 +493,6 @@ func TestAccLinuxVirtualMachineScaleSet_otherTerminationNotification(t *testing. }) } -// TODO remove TestAccLinuxVirtualMachineScaleSet_otherTerminationNotificationMigration in 4.0 -func TestAccLinuxVirtualMachineScaleSet_otherTerminationNotificationMigration(t *testing.T) { - if features.FourPointOhBeta() { - t.Skip("removing in 4.0") - } - data := acceptance.BuildTestData(t, "azurerm_linux_virtual_machine_scale_set", "test") - r := LinuxVirtualMachineScaleSetResource{} - - data.ResourceTest(t, r, []acceptance.TestStep{ - // old: terminate_notification - { - Config: r.otherTerminateNotification(data, true), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("terminate_notification.#").HasValue("1"), - check.That(data.ResourceName).Key("terminate_notification.0.enabled").HasValue("true"), - ), - }, - data.ImportStep("admin_password"), - // new: termination_notification - { - Config: r.otherTerminationNotification(data, true), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("termination_notification.#").HasValue("1"), - check.That(data.ResourceName).Key("termination_notification.0.enabled").HasValue("true"), - ), - }, - data.ImportStep("admin_password"), - }) -} - func TestAccLinuxVirtualMachineScaleSet_otherAutomaticRepairsPolicy(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_linux_virtual_machine_scale_set", "test") r := LinuxVirtualMachineScaleSetResource{} @@ -2114,50 +2061,6 @@ resource "azurerm_linux_virtual_machine_scale_set" "test" { `, r.template(data), data.RandomInteger) } -func (r LinuxVirtualMachineScaleSetResource) otherScaleInPolicy(data acceptance.TestData) string { - return fmt.Sprintf(` -%s - -resource "azurerm_linux_virtual_machine_scale_set" "test" { - name = "acctestvmss-%d" - resource_group_name = azurerm_resource_group.test.name - location = azurerm_resource_group.test.location - sku = "Standard_F2" - instances = 1 - admin_username = "adminuser" - admin_password = "P@ssword1234!" - - disable_password_authentication = false - - source_image_reference { - publisher = "Canonical" - offer = "0001-com-ubuntu-server-jammy" - sku = "22_04-lts" - version = "latest" - } - - os_disk { - disk_size_gb = 30 - storage_account_type = "Standard_LRS" - caching = "ReadWrite" - } - - network_interface { - name = "example" - primary = true - - ip_configuration { - name = "internal" - primary = true - subnet_id = azurerm_subnet.test.id - } - } - - scale_in_policy = "Default" -} -`, r.template(data), data.RandomInteger) -} - func (r LinuxVirtualMachineScaleSetResource) otherScaleInDefault(data acceptance.TestData) string { return fmt.Sprintf(` %s @@ -2250,53 +2153,6 @@ resource "azurerm_linux_virtual_machine_scale_set" "test" { `, r.template(data), data.RandomInteger) } -// TODO remove otherTerminateNotification in 4.0 -func (r LinuxVirtualMachineScaleSetResource) otherTerminateNotification(data acceptance.TestData, enabled bool) string { - return fmt.Sprintf(` -%s - -resource "azurerm_linux_virtual_machine_scale_set" "test" { - name = "acctestvmss-%d" - resource_group_name = azurerm_resource_group.test.name - location = azurerm_resource_group.test.location - sku = "Standard_F2" - instances = 1 - admin_username = "adminuser" - admin_password = "P@ssword1234!" - - disable_password_authentication = false - - source_image_reference { - publisher = "Canonical" - offer = "0001-com-ubuntu-server-jammy" - sku = "22_04-lts" - version = "latest" - } - - os_disk { - disk_size_gb = 30 - storage_account_type = "Standard_LRS" - caching = "ReadWrite" - } - - network_interface { - name = "example" - primary = true - - ip_configuration { - name = "internal" - primary = true - subnet_id = azurerm_subnet.test.id - } - } - - terminate_notification { - enabled = %t - } -} -`, r.template(data), data.RandomInteger, enabled) -} - func (r LinuxVirtualMachineScaleSetResource) otherTerminationNotification(data acceptance.TestData, enabled bool) string { return fmt.Sprintf(` %s diff --git a/internal/services/compute/managed_disk_resource.go b/internal/services/compute/managed_disk_resource.go index 4db1c1b8933d..f79ffeaaf05f 100644 --- a/internal/services/compute/managed_disk_resource.go +++ b/internal/services/compute/managed_disk_resource.go @@ -23,7 +23,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" @@ -308,9 +307,6 @@ func resourceManagedDisk() *pluginsdk.Resource { // Encryption Settings cannot be disabled once enabled CustomizeDiff: pluginsdk.CustomDiffWithAll( pluginsdk.ForceNewIfChange("encryption_settings", func(ctx context.Context, old, new, meta interface{}) bool { - if !features.FourPointOhBeta() { - return false - } return len(old.([]interface{})) > 0 && len(new.([]interface{})) == 0 }), ), diff --git a/internal/services/compute/orchestrated_virtual_machine_scale_set.go b/internal/services/compute/orchestrated_virtual_machine_scale_set.go index 56e304b32f2e..6c58795b57e8 100644 --- a/internal/services/compute/orchestrated_virtual_machine_scale_set.go +++ b/internal/services/compute/orchestrated_virtual_machine_scale_set.go @@ -17,7 +17,6 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/publicipprefixes" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" azValidate "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -192,7 +191,7 @@ func OrchestratedVirtualMachineScaleSetLinuxConfigurationSchema() *pluginsdk.Sch } func OrchestratedVirtualMachineScaleSetExtensionsSchema() *pluginsdk.Schema { - schema := &pluginsdk.Schema{ + return &pluginsdk.Schema{ Type: pluginsdk.TypeSet, Optional: true, Computed: true, @@ -268,15 +267,6 @@ func OrchestratedVirtualMachineScaleSetExtensionsSchema() *pluginsdk.Schema { }, }, } - - if !features.FourPointOhBeta() { - schema.Elem.(*pluginsdk.Resource).Schema["failure_suppression_enabled"] = &pluginsdk.Schema{ - Type: pluginsdk.TypeBool, - Optional: true, - } - } - - return schema } func OrchestratedVirtualMachineScaleSetNetworkInterfaceSchema() *pluginsdk.Schema { diff --git a/internal/services/compute/orchestrated_virtual_machine_scale_set_resource.go b/internal/services/compute/orchestrated_virtual_machine_scale_set_resource.go index ad38287dab93..d696af2695fa 100644 --- a/internal/services/compute/orchestrated_virtual_machine_scale_set_resource.go +++ b/internal/services/compute/orchestrated_virtual_machine_scale_set_resource.go @@ -27,7 +27,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" computeValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" @@ -169,17 +168,11 @@ func resourceOrchestratedVirtualMachineScaleSet() *pluginsdk.Resource { "extension_operations_enabled": { Type: pluginsdk.TypeBool, Optional: true, - Default: func() interface{} { - if !features.FourPointOhBeta() { - return nil - } - return true - }(), - Computed: !features.FourPointOhBeta(), + Default: true, ForceNew: true, }, - // Due to bug in RP extensions cannot curretntly be supported in Terraform ETA for full support is mid Jan 2022 + // Due to bug in RP extensions cannot currently be supported in Terraform ETA for full support is mid Jan 2022 "extension": OrchestratedVirtualMachineScaleSetExtensionsSchema(), "extensions_time_budget": { @@ -601,19 +594,10 @@ func resourceOrchestratedVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData, virtualMachineProfile.OsProfile = vmssOsProfile } - if !features.FourPointOhBeta() { - if !pluginsdk.IsExplicitlyNullInConfig(d, "extension_operations_enabled") { - if virtualMachineProfile.OsProfile == nil { - virtualMachineProfile.OsProfile = &virtualmachinescalesets.VirtualMachineScaleSetOSProfile{} - } - virtualMachineProfile.OsProfile.AllowExtensionOperations = pointer.To(extensionOperationsEnabled) - } - } else { - if virtualMachineProfile.OsProfile == nil { - virtualMachineProfile.OsProfile = &virtualmachinescalesets.VirtualMachineScaleSetOSProfile{} - } - virtualMachineProfile.OsProfile.AllowExtensionOperations = pointer.To(extensionOperationsEnabled) + if virtualMachineProfile.OsProfile == nil { + virtualMachineProfile.OsProfile = &virtualmachinescalesets.VirtualMachineScaleSetOSProfile{} } + virtualMachineProfile.OsProfile.AllowExtensionOperations = pointer.To(extensionOperationsEnabled) if v, ok := d.GetOk("boot_diagnostics"); ok { virtualMachineProfile.DiagnosticsProfile = expandBootDiagnosticsVMSS(v.([]interface{})) diff --git a/internal/services/compute/orchestrated_virtual_machine_scale_set_resource_test.go b/internal/services/compute/orchestrated_virtual_machine_scale_set_resource_test.go index 7f3b3597a90d..00e36da8d254 100644 --- a/internal/services/compute/orchestrated_virtual_machine_scale_set_resource_test.go +++ b/internal/services/compute/orchestrated_virtual_machine_scale_set_resource_test.go @@ -15,7 +15,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -2216,11 +2215,7 @@ resource "azurerm_application_gateway" "test" { } func (OrchestratedVirtualMachineScaleSetResource) natgateway_template(data acceptance.TestData) string { - // NOTE: In v4.0 the 'azurerm_public_ip' resources 'sku' field will default to 'Standard' instead of 'Basic'... publicIpSku := "Standard" - if !features.FourPointOhBeta() { - publicIpSku = "Basic" - } return fmt.Sprintf(` resource "azurerm_public_ip" "test" { diff --git a/internal/services/compute/shared_image_version_data_source_test.go b/internal/services/compute/shared_image_version_data_source_test.go index 3060e51c6892..e0f8ca4d25ff 100644 --- a/internal/services/compute/shared_image_version_data_source_test.go +++ b/internal/services/compute/shared_image_version_data_source_test.go @@ -9,7 +9,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" ) type SharedImageVersionDataSource struct{} @@ -68,10 +67,6 @@ func TestAccDataSourceSharedImageVersion_excludeFromLatest(t *testing.T) { r := SharedImageVersionDataSource{} expectedVersion := "0.0.1" - if !features.FourPointOhBeta() { - // `ExcludeFromLatest` is not considered in 3.0 so `0.0.2` will still be the latest image - expectedVersion = "0.0.2" - } data.DataSourceTest(t, []acceptance.TestStep{ { diff --git a/internal/services/compute/snapshot_resource.go b/internal/services/compute/snapshot_resource.go index c7166c707efe..493e2b592d93 100644 --- a/internal/services/compute/snapshot_resource.go +++ b/internal/services/compute/snapshot_resource.go @@ -18,7 +18,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" @@ -140,9 +139,6 @@ func resourceSnapshot() *pluginsdk.Resource { // Encryption Settings cannot be disabled once enabled CustomizeDiff: pluginsdk.CustomDiffWithAll( pluginsdk.ForceNewIfChange("encryption_settings", func(ctx context.Context, old, new, meta interface{}) bool { - if !features.FourPointOhBeta() { - return false - } return len(old.([]interface{})) > 0 && len(new.([]interface{})) == 0 }), ), diff --git a/internal/services/compute/virtual_machine_scale_set.go b/internal/services/compute/virtual_machine_scale_set.go index 704b581d8e0b..b38a4b638679 100644 --- a/internal/services/compute/virtual_machine_scale_set.go +++ b/internal/services/compute/virtual_machine_scale_set.go @@ -17,7 +17,6 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/networksecuritygroups" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/publicipprefixes" azValidate "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -128,13 +127,6 @@ func VirtualMachineScaleSetGalleryApplicationSchema() *pluginsdk.Schema { Type: pluginsdk.TypeList, Optional: true, MaxItems: 100, - Computed: !features.FourPointOhBeta(), - ConflictsWith: func() []string { - if !features.FourPointOhBeta() { - return []string{"gallery_applications"} - } - return []string{} - }(), Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ "version_id": { @@ -172,53 +164,6 @@ func VirtualMachineScaleSetGalleryApplicationSchema() *pluginsdk.Schema { } } -func VirtualMachineScaleSetGalleryApplicationsSchema() *pluginsdk.Schema { - return &pluginsdk.Schema{ - Type: pluginsdk.TypeList, - Optional: true, - MaxItems: 100, - Computed: !features.FourPointOhBeta(), - ConflictsWith: []string{"gallery_application"}, - Deprecated: "`gallery_applications` has been renamed to `gallery_application` and will be deprecated in 4.0", - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "package_reference_id": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: galleryapplicationversions.ValidateApplicationVersionID, - Deprecated: "`package_reference_id` has been renamed to `version_id` and will be deprecated in 4.0", - }, - - // Example: https://mystorageaccount.blob.core.windows.net/configurations/settings.config - "configuration_reference_blob_uri": { - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IsURLWithHTTPorHTTPS, - Deprecated: "`configuration_reference_blob_uri` has been renamed to `configuration_blob_uri` and will be deprecated in 4.0", - }, - - "order": { - Type: pluginsdk.TypeInt, - Optional: true, - Default: 0, - ForceNew: true, - ValidateFunc: validation.IntBetween(0, 2147483647), - }, - - // NOTE: Per the service team, "this is a pass through value that we just add to the model but don't depend on. It can be any string." - "tag": { - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - }, - }, - } -} - func expandVirtualMachineScaleSetGalleryApplication(input []interface{}) *[]virtualmachinescalesets.VMGalleryApplication { if len(input) == 0 { return nil @@ -281,68 +226,6 @@ func flattenVirtualMachineScaleSetGalleryApplication(input *[]virtualmachinescal return out } -func expandVirtualMachineScaleSetGalleryApplications(input []interface{}) *[]virtualmachinescalesets.VMGalleryApplication { - if len(input) == 0 { - return nil - } - - out := make([]virtualmachinescalesets.VMGalleryApplication, 0) - - for _, v := range input { - packageReferenceId := v.(map[string]interface{})["package_reference_id"].(string) - configurationReference := v.(map[string]interface{})["configuration_reference_blob_uri"].(string) - order := v.(map[string]interface{})["order"].(int) - tag := v.(map[string]interface{})["tag"].(string) - - app := &virtualmachinescalesets.VMGalleryApplication{ - PackageReferenceId: packageReferenceId, - ConfigurationReference: pointer.To(configurationReference), - Order: pointer.To(int64(order)), - Tags: pointer.To(tag), - } - - out = append(out, *app) - } - - return &out -} - -func flattenVirtualMachineScaleSetGalleryApplications(input *[]virtualmachinescalesets.VMGalleryApplication) []interface{} { - if len(*input) == 0 { - return nil - } - - out := make([]interface{}, 0) - - for _, v := range *input { - var configurationReference, tag string - var order int - - if v.ConfigurationReference != nil { - configurationReference = *v.ConfigurationReference - } - - if v.Order != nil { - order = int(*v.Order) - } - - if v.Tags != nil { - tag = *v.Tags - } - - app := map[string]interface{}{ - "package_reference_id": v.PackageReferenceId, - "configuration_reference_blob_uri": configurationReference, - "order": order, - "tag": tag, - } - - out = append(out, app) - } - - return out -} - func VirtualMachineScaleSetScaleInPolicySchema() *pluginsdk.Schema { return &pluginsdk.Schema{ Type: pluginsdk.TypeList, @@ -1804,32 +1687,6 @@ func FlattenVirtualMachineScaleSetRollingUpgradePolicy(input *virtualmachinescal } } -// 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 4.0.", - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "enabled": { - Type: pluginsdk.TypeBool, - Required: true, - }, - "timeout": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: azValidate.ISO8601DurationBetween("PT5M", "PT15M"), - Default: "PT5M", - }, - }, - }, - ConflictsWith: []string{"termination_notification"}, - } -} - func VirtualMachineScaleSetTerminationNotificationSchema() *pluginsdk.Schema { return &pluginsdk.Schema{ Type: pluginsdk.TypeList, @@ -1850,12 +1707,6 @@ func VirtualMachineScaleSetTerminationNotificationSchema() *pluginsdk.Schema { }, }, }, - ConflictsWith: func() []string { - if !features.FourPointOhBeta() { - return []string{"terminate_notification"} - } - return []string{} - }(), } } @@ -2039,13 +1890,6 @@ func VirtualMachineScaleSetExtensionsSchema() *pluginsdk.Schema { Set: virtualMachineScaleSetExtensionHash, } - if !features.FourPointOhBeta() { - schema.Elem.(*pluginsdk.Resource).Schema["automatic_upgrade_enabled"] = &pluginsdk.Schema{ - Type: pluginsdk.TypeBool, - Optional: true, - } - } - return schema } 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 029a40be5405..d82fca7822f6 100644 --- a/internal/services/compute/windows_virtual_machine_scale_set_resource.go +++ b/internal/services/compute/windows_virtual_machine_scale_set_resource.go @@ -26,7 +26,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" computeValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/base64" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" @@ -227,14 +226,6 @@ func resourceWindowsVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData, meta }, } - if !features.FourPointOhBeta() { - if galleryApplications := expandVirtualMachineScaleSetGalleryApplications(d.Get("gallery_applications").([]interface{})); galleryApplications != nil { - virtualMachineProfile.ApplicationProfile = &virtualmachinescalesets.ApplicationProfile{ - GalleryApplications: galleryApplications, - } - } - } - if galleryApplications := expandVirtualMachineScaleSetGalleryApplication(d.Get("gallery_application").([]interface{})); galleryApplications != nil { virtualMachineProfile.ApplicationProfile = &virtualmachinescalesets.ApplicationProfile{ GalleryApplications: galleryApplications, @@ -265,13 +256,7 @@ func resourceWindowsVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData, meta return fmt.Errorf("`extension_operations_enabled` cannot be set to `true` when `provision_vm_agent` is set to `false`") } - if !features.FourPointOhBeta() { - if !pluginsdk.IsExplicitlyNullInConfig(d, "extension_operations_enabled") { - virtualMachineProfile.OsProfile.AllowExtensionOperations = pointer.To(v) - } - } else { - virtualMachineProfile.OsProfile.AllowExtensionOperations = pointer.To(v) - } + virtualMachineProfile.OsProfile.AllowExtensionOperations = pointer.To(v) } if v, ok := d.GetOk("extensions_time_budget"); ok { @@ -383,12 +368,6 @@ func resourceWindowsVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData, meta virtualMachineProfile.OsProfile.WindowsConfiguration.TimeZone = pointer.To(v.(string)) } - if !features.FourPointOhBeta() { - if v, ok := d.GetOk("terminate_notification"); ok { - virtualMachineProfile.ScheduledEventsProfile = ExpandVirtualMachineScaleSetScheduledEventsProfile(v.([]interface{})) - } - } - if v, ok := d.GetOk("termination_notification"); ok { virtualMachineProfile.ScheduledEventsProfile = ExpandVirtualMachineScaleSetScheduledEventsProfile(v.([]interface{})) } @@ -432,18 +411,6 @@ func resourceWindowsVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData, meta }, } - if !features.FourPointOhBeta() { - scaleInPolicy := &virtualmachinescalesets.ScaleInPolicy{ - Rules: &[]virtualmachinescalesets.VirtualMachineScaleSetScaleInRules{virtualmachinescalesets.VirtualMachineScaleSetScaleInRules(string(virtualmachinescalesets.VirtualMachineScaleSetScaleInRulesDefault))}, - ForceDeletion: pointer.To(false), - } - - if v, ok := d.GetOk("scale_in_policy"); ok { - scaleInPolicy.Rules = &[]virtualmachinescalesets.VirtualMachineScaleSetScaleInRules{virtualmachinescalesets.VirtualMachineScaleSetScaleInRules(v.(string))} - } - - props.Properties.ScaleInPolicy = scaleInPolicy - } if v, ok := d.GetOk("scale_in"); ok { if v := ExpandVirtualMachineScaleSetScaleInPolicy(v.([]interface{})); v != nil { props.Properties.ScaleInPolicy = v @@ -735,24 +702,6 @@ func resourceWindowsVirtualMachineScaleSetUpdate(d *pluginsdk.ResourceData, meta } } - if !features.FourPointOhBeta() { - if d.HasChange("scale_in_policy") { - updateScaleInPolicy := &virtualmachinescalesets.ScaleInPolicy{} - - if d.HasChange("scale_in_policy") { - scaleInPolicy := d.Get("scale_in_policy").(string) - updateScaleInPolicy.Rules = &[]virtualmachinescalesets.VirtualMachineScaleSetScaleInRules{virtualmachinescalesets.VirtualMachineScaleSetScaleInRules(scaleInPolicy)} - } - - updateProps.ScaleInPolicy = updateScaleInPolicy - } - - if d.HasChange("terminate_notification") { - notificationRaw := d.Get("terminate_notification").([]interface{}) - updateProps.VirtualMachineProfile.ScheduledEventsProfile = ExpandVirtualMachineScaleSetScheduledEventsProfile(notificationRaw) - } - } - if d.HasChange("termination_notification") { notificationRaw := d.Get("termination_notification").([]interface{}) updateProps.VirtualMachineProfile.ScheduledEventsProfile = ExpandVirtualMachineScaleSetScheduledEventsProfile(notificationRaw) @@ -961,17 +910,6 @@ func resourceWindowsVirtualMachineScaleSetRead(d *pluginsdk.ResourceData, meta i d.Set("zone_balance", props.ZoneBalance) d.Set("scale_in", FlattenVirtualMachineScaleSetScaleInPolicy(props.ScaleInPolicy)) - if !features.FourPointOhBeta() { - rule := string(virtualmachinescalesets.VirtualMachineScaleSetScaleInRulesDefault) - if props.ScaleInPolicy != nil { - if rules := props.ScaleInPolicy.Rules; rules != nil && len(*rules) > 0 { - rule = string((*rules)[0]) - } - } - - d.Set("scale_in_policy", rule) - } - if props.SpotRestorePolicy != nil { d.Set("spot_restore", FlattenVirtualMachineScaleSetSpotRestorePolicy(props.SpotRestorePolicy)) } @@ -1015,10 +953,6 @@ func resourceWindowsVirtualMachineScaleSetRead(d *pluginsdk.ResourceData, meta i if profile.ApplicationProfile != nil && profile.ApplicationProfile.GalleryApplications != nil { d.Set("gallery_application", flattenVirtualMachineScaleSetGalleryApplication(profile.ApplicationProfile.GalleryApplications)) - - if !features.FourPointOhBeta() { - d.Set("gallery_applications", flattenVirtualMachineScaleSetGalleryApplications(profile.ApplicationProfile.GalleryApplications)) - } } // the service just return empty when this is not assigned when provisioned @@ -1109,14 +1043,6 @@ func resourceWindowsVirtualMachineScaleSetRead(d *pluginsdk.ResourceData, meta i d.Set("health_probe_id", healthProbeId) } - 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) - } - } - } - if scheduleProfile := profile.ScheduledEventsProfile; scheduleProfile != nil { if err := d.Set("termination_notification", FlattenVirtualMachineScaleSetScheduledEventsProfile(scheduleProfile)); err != nil { return fmt.Errorf("setting `termination_notification`: %+v", err) @@ -1223,7 +1149,7 @@ func resourceWindowsVirtualMachineScaleSetDelete(d *pluginsdk.ResourceData, meta } func resourceWindowsVirtualMachineScaleSetSchema() map[string]*pluginsdk.Schema { - resourceSchema := map[string]*pluginsdk.Schema{ + return map[string]*pluginsdk.Schema{ "name": { Type: pluginsdk.TypeString, Required: true, @@ -1336,13 +1262,7 @@ func resourceWindowsVirtualMachineScaleSetSchema() map[string]*pluginsdk.Schema "extension_operations_enabled": { Type: pluginsdk.TypeBool, Optional: true, - Default: func() interface{} { - if !features.FourPointOhBeta() { - return nil - } - return true - }(), - Computed: !features.FourPointOhBeta(), + Default: true, ForceNew: true, }, @@ -1534,24 +1454,4 @@ func resourceWindowsVirtualMachineScaleSetSchema() map[string]*pluginsdk.Schema Computed: true, }, } - - if !features.FourPointOhBeta() { - resourceSchema["gallery_applications"] = VirtualMachineScaleSetGalleryApplicationsSchema() - resourceSchema["terminate_notification"] = VirtualMachineScaleSetTerminateNotificationSchema() - - resourceSchema["scale_in_policy"] = &schema.Schema{ - Type: pluginsdk.TypeString, - Optional: true, - Computed: !features.FourPointOhBeta(), - ValidateFunc: validation.StringInSlice([]string{ - string(virtualmachinescalesets.VirtualMachineScaleSetScaleInRulesDefault), - string(virtualmachinescalesets.VirtualMachineScaleSetScaleInRulesNewestVM), - string(virtualmachinescalesets.VirtualMachineScaleSetScaleInRulesOldestVM), - }, false), - Deprecated: "`scale_in_policy` will be removed in favour of the `scale_in` code block in version 4.0 of the AzureRM Provider.", - ConflictsWith: []string{"scale_in"}, - } - } - - return resourceSchema } diff --git a/internal/services/compute/windows_virtual_machine_scale_set_resource_other_test.go b/internal/services/compute/windows_virtual_machine_scale_set_resource_other_test.go index af95cb84f3bd..422f071bdde3 100644 --- a/internal/services/compute/windows_virtual_machine_scale_set_resource_other_test.go +++ b/internal/services/compute/windows_virtual_machine_scale_set_resource_other_test.go @@ -16,7 +16,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" ) func TestAccWindowsVirtualMachineScaleSet_otherAdditionalUnattendContent(t *testing.T) { @@ -554,26 +553,6 @@ func TestAccWindowsVirtualMachineScaleSet_otherUpgradeMode(t *testing.T) { }) } -func TestAccWindowsVirtualMachineScaleSet_otherScaleInPolicy(t *testing.T) { - if features.FourPointOhBeta() { - t.Skipf("Skipped the 'scale_in_policy' property has been deprecated in the 4.0 provider.") - } - - data := acceptance.BuildTestData(t, "azurerm_windows_virtual_machine_scale_set", "test") - r := WindowsVirtualMachineScaleSetResource{} - - data.ResourceTest(t, r, []acceptance.TestStep{ - { - Config: r.otherScaleInPolicy(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("scale_in_policy").HasValue("Default"), - ), - }, - data.ImportStep("admin_password"), - }) -} - func TestAccWindowsVirtualMachineScaleSet_otherScaleIn(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_windows_virtual_machine_scale_set", "test") r := WindowsVirtualMachineScaleSetResource{} @@ -636,38 +615,6 @@ func TestAccWindowsVirtualMachineScaleSet_otherTerminationNotification(t *testin }) } -// TODO remove TestAccWindowsVirtualMachineScaleSet_otherTerminationNotificationMigration in 4.0 -func TestAccWindowsVirtualMachineScaleSet_otherTerminationNotificationMigration(t *testing.T) { - if features.FourPointOhBeta() { - t.Skip("this test is being removed in 4.0") - } - data := acceptance.BuildTestData(t, "azurerm_windows_virtual_machine_scale_set", "test") - r := WindowsVirtualMachineScaleSetResource{} - - data.ResourceTest(t, r, []acceptance.TestStep{ - // old: terminate_notification - { - Config: r.otherTerminateNotification(data, true), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("terminate_notification.#").HasValue("1"), - check.That(data.ResourceName).Key("terminate_notification.0.enabled").HasValue("true"), - ), - }, - data.ImportStep("admin_password"), - // new: termination_notification - { - Config: r.otherTerminationNotification(data, true), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("termination_notification.#").HasValue("1"), - check.That(data.ResourceName).Key("termination_notification.0.enabled").HasValue("true"), - ), - }, - data.ImportStep("admin_password"), - }) -} - func TestAccWindowsVirtualMachineScaleSet_otherAutomaticRepairsPolicy(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_windows_virtual_machine_scale_set", "test") r := WindowsVirtualMachineScaleSetResource{} @@ -2517,47 +2464,6 @@ resource "azurerm_windows_virtual_machine_scale_set" "test" { `, r.template(data), data.RandomString) } -func (r WindowsVirtualMachineScaleSetResource) otherScaleInPolicy(data acceptance.TestData) string { - return fmt.Sprintf(` -%s - -resource "azurerm_windows_virtual_machine_scale_set" "test" { - name = local.vm_name - resource_group_name = azurerm_resource_group.test.name - location = azurerm_resource_group.test.location - sku = "Standard_F2" - instances = 1 - admin_username = "adminuser" - admin_password = "P@ssword1234!" - - source_image_reference { - publisher = "MicrosoftWindowsServer" - offer = "WindowsServer" - sku = "2019-Datacenter" - version = "latest" - } - - os_disk { - storage_account_type = "Standard_LRS" - caching = "ReadWrite" - } - - network_interface { - name = "example" - primary = true - - ip_configuration { - name = "internal" - primary = true - subnet_id = azurerm_subnet.test.id - } - } - - scale_in_policy = "Default" -} -`, r.template(data)) -} - func (r WindowsVirtualMachineScaleSetResource) otherScaleInDefault(data acceptance.TestData) string { return fmt.Sprintf(` %s @@ -2644,50 +2550,6 @@ resource "azurerm_windows_virtual_machine_scale_set" "test" { `, r.template(data)) } -// TODO remove otherTerminateNotification in 4.0 -func (r WindowsVirtualMachineScaleSetResource) otherTerminateNotification(data acceptance.TestData, enabled bool) string { - return fmt.Sprintf(` -%s - -resource "azurerm_windows_virtual_machine_scale_set" "test" { - name = local.vm_name - resource_group_name = azurerm_resource_group.test.name - location = azurerm_resource_group.test.location - sku = "Standard_F2" - instances = 1 - admin_username = "adminuser" - admin_password = "P@ssword1234!" - - source_image_reference { - publisher = "MicrosoftWindowsServer" - offer = "WindowsServer" - sku = "2019-Datacenter" - version = "latest" - } - - os_disk { - storage_account_type = "Standard_LRS" - caching = "ReadWrite" - } - - network_interface { - name = "example" - primary = true - - ip_configuration { - name = "internal" - primary = true - subnet_id = azurerm_subnet.test.id - } - } - - terminate_notification { - enabled = %t - } -} -`, r.template(data), enabled) -} - func (r WindowsVirtualMachineScaleSetResource) otherTerminationNotification(data acceptance.TestData, enabled bool) string { return fmt.Sprintf(` %s