Follow dba-ninja.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

dba-ninja.com Links

Dba_db2_button

Sqlserver_dba_button

How to create a CNAME record for a Route 53 Domain

22 March,2024 by Rambler

Question : How do I create a CNAME record on an AWS Route 53 Private Hosted Zone (PHZ)   Dimain using AWS CLI ?   I want to use the CNAME record to route traffic to an Aurora Cluster 

 

Answer: Assuming you have a valid PHZ set up with with a domain . You can check by issuing the following AWS CLI commands in the AWS account .

 

--get the Id of the domain 
aws route53 list-hosted-zones-by-name --query "HostedZones[].[Name,Id]" --output table
--use the Id to view the vpc- details 
aws route53 get-hosted-zone --id 

Once you've confirmed there is a valid PHZ and domain , the next step is to create the CNAME record. You will need at minimum some information :

  • Hosted Zone ID - use the commands above 
  • The subdomain to be used as part of the referemces

 

Create a json file similar to the ddetails below . This will create a new CNAME record on a PHZ domain "mydomain.net" . Th  new cname will be "jvr53.mydomain.net" routing traffic to "myaurora.test-cluster-prim-27022024.cluster-yeyeyeye.us-west-2.rds.amazonaws.com"

 

{
  "Comment": "r53_cname_test",
  "Changes": [
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "jvr53.mydomain.net",
        "Type": "CNAME",
        "TTL": 300,
        "ResourceRecords": [
          {
            "Value": "myaurora.test-cluster-prim-27022024.cluster-yeyeyeye.us-west-2.rds.amazonaws.com."
          }
         ]
      }
    }
   ]
}



The next step is to issue the aws cli command  using the route53  service call to change-resource-record-sets,  referencing the json file created above .

 

aws route53 change-resource-record-sets  --hosted-zone-id /hostedzone/VB0000000NMCCCCC  --change-batch file://create_cname.json

To view the list of cnames & related record set details  associated with the domain 

aws route53 list-resource-record-sets --hosted-zone-id replace_with_hostingid

nn

If you want to just view the name portion of the cname :

 

aws route53 list-resource-record-sets --hosted-zone-id  replace_with_hostingid --query "ResourceRecordSets[*].Name"

for more AWS CLI commands - AWS CLI Cheatsheet - RDS, AWS Backup , DMS, IAM, Security Token Service,KMS,EC2, DynamoDB,VPC,Aurora, Aurora Global,RESOURCEGROUPSTAGGINGAPI,DocumentDB,CloudTrail


Author: Rambler (http://www.dba-ninja.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to create a CNAME record for a Route 53 Domain


dba-ninja.com