问题
We have a vpc in aws, it there some feature provided by aws to automatically add private DNS to route53 when manually launch an instance.
回答1:
If you have installed boto, you can add / update DNS settings like this:
DNS_ADDRESS="`ec2metadata | grep 'public-hostname:' | cut -d ' ' -f 2`"
/usr/local/bin/route53 change_record <Hosted zone ID> foo.bar.com. CNAME $DNS_ADDRESS 300
DNS_ADDRESS
is the AWS DNS name of the instance such as ec2-1-2-3-4.eu-west-1.compute.amazonaws.com
The second line creates a CNAME with 5min TTL. You need to add the hosted zone ID of the domain you want to change.
If you put this snippet into /etc/rc.local
, the instance will automatically update / create the CNAME when it's booting.
I'm not sure what you mean with "private" DNS. Route53 provides a (public) DNS service. However, if your instances are inside a VPC there's no harm to make the DNS entries public, since no one can access them anyway.
回答2:
Sample Script:
/usr/local/bin/route53 change_record $Hosted_zone_ID $DNS-Name A $IP 300
$Hosted_zone_ID
, $DNS-Name
, $IP
are place holders. Replace them with actual values to run script
回答3:
There is no feature built-in to AWS that does this automatically, but AWS provides a feature that allows you to customize all kinds of things using simple workflows and a bit of Javascript.
For example, we use an auto scaling group to launch instances as needed, and we have used this blog article as a sample of how to set up an AWS Lambda function that receives SNS notifications from the auto scaling group when an instance goes up and down, and adds a custom DNS name to the route 53 zone. It should be pretty straight forward to customize it for your needs.
来源:https://stackoverflow.com/questions/24907246/is-there-an-aws-provided-feature-to-automatically-add-private-dns-to-route53