Skip to content

Instantly share code, notes, and snippets.

@mvanholsteijn
Last active March 29, 2021 12:08
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mvanholsteijn/964a267c5295028eeb1da05e842032c7 to your computer and use it in GitHub Desktop.
a short shell script to copy the contents from one Route53 hosted zone to the other
#!/bin/bash
aws route53 list-resource-record-sets \
--hosted-zone ${SOURCE_HOSTED_ZONE_ID} \
--query '{Changes: ResourceRecordSets[?Type != `NS` && Type != `SOA`].{"Action": `UPSERT`, "ResourceRecordSet": @ }}' > changeset.json
aws route53 change-resource-record-sets \
--hosted-zone ${TARGET_HOSTED_ZONE_ID} \
--change-batch "$(<changeset.json)"
@pstanton237
Copy link

Thanks! It helped a lot.
But it only worked after I changed INSERT to CREATE on the 4th line.

An error occurred (InvalidInput) when calling the ChangeResourceRecordSets operation (reached max retries: 2): Invalid XML ; cvc-enumeration-valid: Value 'INSERT' is not facet-valid with respect to enumeration '[CREATE, DELETE, UPSERT]'. It must be a value from the enumeration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment