Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_site_recovery_replicated_vm - support 'target_availability_zone' argument #15617

Merged
merged 14 commits into from
Mar 23, 2022
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,24 @@ func resourceSiteRecoveryReplicatedVM() *pluginsdk.Resource {
Optional: true,
ValidateFunc: azure.ValidateResourceID,
DiffSuppressFunc: suppress.CaseDifference,
ConflictsWith: []string{
"target_availability_zone",
},
},
"target_availability_zone": {
cheng514 marked this conversation as resolved.
Show resolved Hide resolved
Type: pluginsdk.TypeString,
Optional: true,
// Default: "None",
Computed: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
"1",
"2",
"3",
}, false),
ConflictsWith: []string{
"target_availability_set_id",
},
cheng514 marked this conversation as resolved.
Show resolved Hide resolved
},
"target_network_id": {
Type: pluginsdk.TypeString,
Expand Down Expand Up @@ -239,6 +257,13 @@ func resourceSiteRecoveryReplicatedItemCreate(d *pluginsdk.ResourceData, meta in
targetAvailabilitySetID = nil
}

var targetAvailabilityZone *string
if zone, isSet := d.GetOk("target_availability_zone"); isSet {
targetAvailabilityZone = utils.String(zone.(string))
} else {
targetAvailabilityZone = nil
}

ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down Expand Up @@ -284,6 +309,7 @@ func resourceSiteRecoveryReplicatedItemCreate(d *pluginsdk.ResourceData, meta in
RecoveryContainerID: &targetProtectionContainerId,
RecoveryResourceGroupID: &targetResourceGroupId,
RecoveryAvailabilitySetID: targetAvailabilitySetID,
RecoveryAvailabilityZone: targetAvailabilityZone,
VMManagedDisks: &managedDisks,
},
},
Expand Down Expand Up @@ -451,6 +477,7 @@ func resourceSiteRecoveryReplicatedItemRead(d *pluginsdk.ResourceData, meta inte
d.Set("source_vm_id", a2aDetails.FabricObjectID)
d.Set("target_resource_group_id", a2aDetails.RecoveryAzureResourceGroupID)
d.Set("target_availability_set_id", a2aDetails.RecoveryAvailabilitySet)
d.Set("target_availability_zone", a2aDetails.RecoveryAvailabilityZone)
d.Set("target_network_id", a2aDetails.SelectedRecoveryAzureNetworkID)
if a2aDetails.ProtectedManagedDisks != nil {
disksOutput := make([]interface{}, 0)
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/site_recovery_replicated_vm.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ The following arguments are supported:

* `target_availability_set_id` - (Optional) Id of availability set that the new VM should belong to when a failover is done.

* `target_availability_zone` - (Optional) Availability zone number that the new VM should belong to when a failover is done.
cheng514 marked this conversation as resolved.
Show resolved Hide resolved

* `managed_disk` - (Required) One or more `managed_disk` block.

* `target_network_id` - (Optional) Network to use when a failover is done (recommended to set if any network_interface is configured for failover).
Expand Down