22

I've just starting using the Amazon Web Services (AWS) and I'm still learning about how it works and what features it provides. I have successfully built two of the sample Java webapps and uploaded them to hosted instances on AWS. If I go to the Elastic Beanstalk tab in my AWS Management Console, I can see each of my hosted webapps, including a URL link to each webapp. The URLs are of the format:

http://myinstancename.elasticbeanstalk.com

I also own a personal domain name. Let's call it "mydomain.com". The domain registrar provides a DNS maintenance page where I can change the A and CNAME records for my domains.

QUESTION: Is it possible for me to configure my domain DNS in conjunction with my AWS account such that I can make my AWS-hosted webapps appear with URLs like this:

http://myinstancename.mydomain.com

EDIT in 2020

This question did not age well over the last 9 years! :)

AWS services are vastly different now in 2020. The DNS service for AWS is named "Route53". It is the first place you should look when your goal is to configure a custom domain name to work with your AWS services.

The person who originally answered this question also mentioned "Elastic IP". That is still a thing in AWS. You can associate an Elastic IP with an AWS server to give that server a public IP address that will not change as long as you (the AWS account holder) continue to own that specific Elastic IP. Then in Route53, you associate your DNS entry with the Elastic IP.

I don't use Elastic Beanstalk anymore in 2020. AWS has better options now.

Jim Tough
  • 14,843
  • 23
  • 75
  • 96

1 Answers1

23

First, I don't know if you use an Elastic IP, it's great:

  • create and attach an elastic IP to one of your instance
  • you have your static IP
  • add a new * sub-domain in your DNS zone, and register a A record with your static IP
  • wait from few hours to 2 days for the DNS propogation

What is really cool with Amazon Elastic IP is that you can rapidly remap it to any other instance and your domain will work instantly without having to change again your DNS zone and waiting for the propagation.

(Elastic IP is free of charge. You pay a small fee only if you don't use it).

Then, if you want to map $1.yourdomain to $1.elasticbeanstalk, personally I will use a proxy/load-balancer like nginx or haproxy, and add a proxy pass. Do you already choose/use one? Which one?

Cédrics
  • 1,974
  • 11
  • 13
  • Thanks for the detailed answer (particularly the 'Elastic IP is free of charge' part). I'll try it out and see what happens. Is the purpose of the load balancer you are suggesting actually for load balancing, or something else? My site will get very little traffic, so I'm not worried about it being overloaded. – Jim Tough Sep 06 '11 at 19:34
  • Nginx, haproxy, etc can be used as a proxy and/or load-balancer. I like nginx and I use it for the both things at the same time. Choose the proxying tool you prefer and lets discuss about the setting you need (maybe via another stackoverflow question with the appropriate proxy name tag so every experts can participate). – Cédrics Sep 06 '11 at 19:44
  • I didn't bother with the load balancer, but the `Elastic IP` and `A Record` worked great. The DNS propogation carried through enough that my new DNS entry was resolving properly from my home and my office within 12 hours. I decided that I really just need to map one name to one webapp for now. So `mywebapp.mydomain.com` is now working with my shiny new AWS Elastic IP holding it all together. Thanks for the help! – Jim Tough Sep 09 '11 at 13:49
  • the Elastic IP + A record seems nice. But what's wrong with just using a CNAME? – Mortimer Nov 13 '12 at 18:31
  • I know this is very old but for the sake of visitors, AWS supports CNANE alias and you can simply create a CNAME record that points to the myapp.elasticbeanstalk.con – advncd Nov 08 '15 at 17:33