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 :
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
This is only a preview. Your comment has not yet been posted.
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.
Posted by: |