Skip to content

Commit

Permalink
azurerm_site_recovery_replicated_vm: restore ConfigModeAttr for `netw…
Browse files Browse the repository at this point in the history
…ork_interface`, `managed_disk`, `unmanaged_disk` blocks
  • Loading branch information
manicminer committed Jul 26, 2024
1 parent 36f9023 commit e4cdf31
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
)

func resourceSiteRecoveryReplicatedVM() *pluginsdk.Resource {
resource := &pluginsdk.Resource{
return &pluginsdk.Resource{
Create: resourceSiteRecoveryReplicatedItemCreate,
Read: resourceSiteRecoveryReplicatedItemRead,
Update: resourceSiteRecoveryReplicatedItemUpdate,
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit e4cdf31

Please sign in to comment.