Created
February 26, 2021 12:29
-
-
Save krymtkts/c68633d449686e1d236d58944ae59882 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[string[]] | |
$ids | |
) | |
foreach ($id in $ids) { | |
$before = Get-R53ResourceRecordSet -HostedZoneId $id | Select-Object -ExpandProperty ResourceRecordSets | Where-object -FilterScript { $_.Type -eq 'A' -and $_.Region } | |
if (!$before) { | |
Write-Error "$id is not target hosted zone id." | |
exit 1 | |
} | |
# changeset to remove a alias record of latency routing policy. | |
$del = New-Object Amazon.Route53.Model.Change ([Amazon.Route53.ChangeAction]::DELETE, $before) | |
# changeset to create a alias record of simple routing policy that copied value from existing alias record. | |
$after = New-Object Amazon.Route53.Model.ResourceRecordSet | |
$after.Name = $before.Name | |
$after.Type = $before.Type | |
$after.AliasTarget = $before.AliasTarget | |
$cre = New-Object Amazon.Route53.Model.Change ([Amazon.Route53.ChangeAction]::CREATE, $after) | |
Edit-R53ResourceRecordSet -HostedZoneId $id -ChangeBatch_Change $del, $cre | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment