diff --git a/internal/services/recoveryservices/site_recovery_replicated_vm_resource.go b/internal/services/recoveryservices/site_recovery_replicated_vm_resource.go index 39f551a769837..2b36caf63fe4e 100644 --- a/internal/services/recoveryservices/site_recovery_replicated_vm_resource.go +++ b/internal/services/recoveryservices/site_recovery_replicated_vm_resource.go @@ -41,7 +41,7 @@ import ( ) func resourceSiteRecoveryReplicatedVM() *pluginsdk.Resource { - resource := &pluginsdk.Resource{ + return &pluginsdk.Resource{ Create: resourceSiteRecoveryReplicatedItemCreate, Read: resourceSiteRecoveryReplicatedItemRead, Update: resourceSiteRecoveryReplicatedItemUpdate, @@ -155,9 +155,11 @@ func resourceSiteRecoveryReplicatedVM() *pluginsdk.Resource { "target_edge_zone": commonschema.EdgeZoneOptionalForceNew(), "unmanaged_disk": { - Type: pluginsdk.TypeSet, - Optional: true, - ForceNew: true, + Type: pluginsdk.TypeSet, + Optional: true, + Computed: true, + ConfigMode: pluginsdk.SchemaConfigModeAttr, + ForceNew: true, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ "disk_uri": { @@ -191,10 +193,12 @@ func resourceSiteRecoveryReplicatedVM() *pluginsdk.Resource { }, "managed_disk": { - Type: pluginsdk.TypeSet, - Optional: true, - ForceNew: true, - Set: resourceSiteRecoveryReplicatedVMDiskHash, + Type: pluginsdk.TypeSet, + Optional: true, + Computed: true, + ConfigMode: pluginsdk.SchemaConfigModeAttr, + ForceNew: true, + Set: resourceSiteRecoveryReplicatedVMDiskHash, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ "disk_id": { @@ -284,123 +288,14 @@ func resourceSiteRecoveryReplicatedVM() *pluginsdk.Resource { }, "network_interface": { - Type: pluginsdk.TypeSet, // use set to avoid diff caused by different orders. - Optional: true, - Elem: networkInterfaceResource(), + Type: pluginsdk.TypeSet, // use set to avoid diff caused by different orders. + Optional: true, + Computed: true, + ConfigMode: pluginsdk.SchemaConfigModeAttr, + Elem: networkInterfaceResource(), }, }, } - - if !features.FourPointOhBeta() { - resource.Schema["network_interface"] = &pluginsdk.Schema{ - Type: pluginsdk.TypeSet, - ConfigMode: pluginsdk.SchemaConfigModeAttr, - Computed: true, - Optional: true, - Elem: networkInterfaceResource(), - } - resource.Schema["unmanaged_disk"] = &pluginsdk.Schema{ - Type: pluginsdk.TypeSet, - Optional: true, - ForceNew: true, - ConfigMode: pluginsdk.SchemaConfigModeAttr, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "disk_uri": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - "staging_storage_account_id": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: azure.ValidateResourceID, - }, - - "target_storage_account_id": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: commonids.ValidateStorageAccountID, - }, - }, - }, - } - resource.Schema["managed_disk"] = &pluginsdk.Schema{ - Type: pluginsdk.TypeSet, - Optional: true, - ForceNew: true, - ConfigMode: pluginsdk.SchemaConfigModeAttr, - Set: resourceSiteRecoveryReplicatedVMDiskHash, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "disk_id": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - "staging_storage_account_id": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: commonids.ValidateStorageAccountID, - }, - - "target_resource_group_id": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: commonids.ValidateResourceGroupID, - }, - - "target_disk_type": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - string(disks.DiskStorageAccountTypesStandardLRS), - string(disks.DiskStorageAccountTypesPremiumLRS), - string(disks.DiskStorageAccountTypesStandardSSDLRS), - string(disks.DiskStorageAccountTypesUltraSSDLRS), - }, false), - }, - - "target_replica_disk_type": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - string(disks.DiskStorageAccountTypesStandardLRS), - string(disks.DiskStorageAccountTypesPremiumLRS), - string(disks.DiskStorageAccountTypesStandardSSDLRS), - string(disks.DiskStorageAccountTypesUltraSSDLRS), - }, false), - }, - - "target_disk_encryption_set_id": { - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: commonids.ValidateDiskEncryptionSetID, - }, - - "target_disk_encryption": { - Type: pluginsdk.TypeList, - Optional: true, - MaxItems: 1, - ConfigMode: pluginsdk.SchemaConfigModeAttr, - Elem: diskEncryptionResource(), - }, - }, - }, - } - } - return resource } func networkInterfaceResource() *pluginsdk.Resource { diff --git a/internal/services/recoveryservices/site_recovery_replicated_vm_resource_test.go b/internal/services/recoveryservices/site_recovery_replicated_vm_resource_test.go index d9b6407bda06b..118106585b850 100644 --- a/internal/services/recoveryservices/site_recovery_replicated_vm_resource_test.go +++ b/internal/services/recoveryservices/site_recovery_replicated_vm_resource_test.go @@ -448,10 +448,6 @@ resource "azurerm_site_recovery_replicated_vm" "test" { azurerm_site_recovery_protection_container_mapping.test, azurerm_site_recovery_network_mapping.test, ] - - lifecycle { - ignore_changes = ["network_interface"] - } } `, r.template(data), data.RandomInteger) }