Sunday, 29 June 2014

Making use of your domain name with EC2 and Elastic IP

So you decided to make use of AWS EC2 to host your web server. You have uploaded your content and you can browse to it by making use of the public DNS name that is assigned by default. By default it will look something like this ec2-54-79-21-210.ap-southeast-2.compute.amazonaws.com. I don't know about you but to me that looks very messy. The DNS name reflects the IP address of your instance, in this case 54.79.21.210. So what about pointing an A record in your DNS server to this IP? Well, yes but not quite that simple. This will work as long as you don't stop your EC2 instance. An instance will change its IP address and therefor it public DNS name when you start it up again and your A record would become invalid.

AWS EC2 provides you with Elastic IP to solve this problem. An Elastic IP address is basically a static IP address that is associated with your account and not with an instance. This means you can assign the address to whatever instance until you decide to release it.


  • Log into the console and go to the EC2 service panel
  • Go to Elastic IPs under Network and Security menu. 
  • Click the blue Allocate New Address button and select Yes, Allocate


  • Your new address will be assigned to your account.

  • Select your instance to associate address.


  • You can now see that the Elastic IP is assigned to your instance under its properties.
  • In your DNS, create an A record that points to your Elastic IP. You should now be able to access your instance by making use of the name specified in the A record.
Your account is limited to 5 Elastic IP addresses and don't cost you anything as long as you use them. If you leave them unassociated you will be charged $0.01/hr.

2 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete