Question

We need to dynamically spin up EC2 instances for new customers, and assign them a subdomain: customer1.mydomain.com, customer2.mydomain.com. I'd like to do this programmatically using the AWS SDK. I'd like to use Route 53 to assign the subdomains to instances.

Questions:

  1. Is it possible to point Route 53 at an instanceId, instead of an IP? Or do I also need to assign an elastic IP to each instance dynamically?

  2. What happens when the hardware crashes? I haven't been able to figure out how to get CloudWatch and Auto Scaling to detect when an instance goes down, and then automatically spin up the (EBS-backed) instance on new hardware and reattach the subdomain.

Was it helpful?

Solution

Yes, you can use Route53 to map DNS names to EC2 instances.

  1. Elastic IP address is the basic way to point to an EC2 instance in a permanent fashion. It can be associated with a replacement instance if you decide your original instance is no longer suitable, and it needs to be re-associated with the instance after stop/start (unless you're in a VPC). When adding it to your DNS, I recommend using a CNAME to the Elastic IP address DNS name.

  2. Auto Scaling can automatically start a replacement instance if it detects that an instance has failed or is no longer passing the health check. However, it will not automatically re-associate Elastic IP addresses. You can combine Auto Scaling with Elastic Load Balancing to have a permanent DNS entry to access the healthy instance including any replacements. You would map your DNS entries as CNAME pointers to the ELB DNS name as described in the docs.

I'm not sure how exactly your question title relates to the question body, but if you are interested in what stop/start does, I've written an article on all the ways it differs from simply rebooting an instance: Rebooting vs. Stop/Start of Amazon EC2 Instance

OTHER TIPS

You might want to look at the new Elastic Network Interfaces.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top