Bootstrap FreeKB - Amazon Web Services (AWS) - Route 53 CNAME records
Amazon Web Services (AWS) - Route 53 CNAME records


This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.

  • An A record can be used to:
    • Route requests from a DNS name to an IPv4 address (for example, from www.example.com to 10.11.12.13)
  • An A Alias record can be used to:
    • Route requests from your Hosted Zone base DNS name to a subdomain, for example from example.com to www.example.com (This can't be done with a CNAME record)
    • Route requests from subdomain "a" to subdomain "b", for example, from foo.example.com to bar.example.com (This can also be done with a CNAME record)
    • Route requests to a AWS service, such as an Elastic Load Balancer or CloudFront Distribution or API Gateway
  • CNAME (canonical name) record (this article) is used to
    • Route requests from subdomain "a" to subdomain "b", for example, from foo.example.com to bar.example.com (This can also be done with an A Alias record)

Route 53 is Amazon Web Services DNS. A CNAME (canonical name) record is used to route requests from DNS name "a" to DNS name "b". For example, let's say you have a Route 53 Hosted Zone for sample.com. In Route 53, a Hosted Zone contains the DNS records. The aws route53 list-hosted-zones command can be used to list your Hosted Zones.

~]$ aws route53 list-hosted-zones
{
    "HostedZones": [
        {
            "Id": "/hostedzone/Z056866DJM1OE9C45GH42",
            "Name": "sample.com.",
            "CallerReference": "RISWorkflow-RD:98abdc50-5adf-1234-abdc-471041234a6c",
            "Config": {
                "Comment": "HostedZone created by Route53 Registrar",
                "PrivateZone": false
            },
            "ResourceRecordSetCount": 3
        }
    ]
}

 

Here is an example of how you could create a CNAME record that forwards requests from foo.sample.com to www.example.com.

aws route53 change-resource-record-sets \
--hosted-zone-id Z056866DJM1OE9C45GH42 \
--change-batch '{ "Changes": [ { "Action": "CREATE", "ResourceRecordSet": { "Name": "foo.sample.com", "Type": "CNAME", "TTL": 300, "ResourceRecords": [ { "Value": "www.example.com" } ] } } ] }'

 

Then going to foo.sample.com in your web browser should forward the request onto www.example.com.

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter a7a193 in the box below so that we can be sure you are a human.