Skip to content

Instantly share code, notes, and snippets.

@tfentonz
Created April 26, 2017 21:46
Show Gist options
  • Select an option

  • Save tfentonz/4783e0fd061ff9dbba3e86e7a2ac3263 to your computer and use it in GitHub Desktop.

Select an option

Save tfentonz/4783e0fd061ff9dbba3e86e7a2ac3263 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Requires an S3 bucket with website redirect for zone apx
# e.g. example.com -> www.example.com
# See http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
# for alias target hosted zone ID.
hosted_zone_id="ZABCDEFGHIJ1K"
alias_target_hosted_zone_id="Z1WCIGYICN2BYD"
aws route53 change-resource-record-sets \
--hosted-zone-id "$hosted_zone_id" \
--region "ap-southeast-2" \
--change-batch "{
\"Changes\": [
{
\"Action\": \"CREATE\",
\"ResourceRecordSet\": {
\"Name\": \"example.com\",
\"Type\": \"A\",
\"AliasTarget\": {
\"HostedZoneId\": \"$alias_target_hosted_zone_id\",
\"DNSName\": \"s3-website-ap-southeast-2.amazonaws.com.\",
\"EvaluateTargetHealth\": false
}
}
}
]
}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment