Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save krymtkts/c68633d449686e1d236d58944ae59882 to your computer and use it in GitHub Desktop.
Save krymtkts/c68633d449686e1d236d58944ae59882 to your computer and use it in GitHub Desktop.
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