Cloud Zone is brought to you in partnership with:

Eric is the Editorial Manager at DZone, Inc. Feel free to contact him at egenesky@dzone.com Eric has posted 804 posts at DZone. You can read more from them at their website. View Full User Profile

Assign a Fixed IP to an AWS EC2 Instance

01.20.2013
| 3635 views |
  • submit to reddit

As described in my previous post the IP (and DNS) of your running EC2 AMI will change after a reboot of that instance. Of course this makes it very hard to make your applications on that machine available for the outside world, like in this case our WordPress blog. That is where Elastic IP comes to the rescue. With this feature you can assign a static IP to your instance.
Assign one to your application as follows:

  • Click on the Elastic IPs link in the AWS Console
  • Screen Shot 2012-12-11 at 12.57.17

  • Allocate a new address
  • Screen Shot 2012-12-11 at 12.46.40

  • Associate the address with a running instance
  • Right click to associate the IP with an instance:
    Screen Shot 2012-12-11 at 12.48.44
    Pick the instance to assign this IP to:
    Screen Shot 2012-12-11 at 12.48.22

  • Note the IP being assigned to your instance
  • Screen Shot 2012-12-11 at 12.49.50

If you go to the IP address you were assigned then you see the home page of your server:
Screen Shot 2012-12-11 at 12.50.16

And the nicest thing is that if you stop and start your instance you will receive a new public DNS but your instance is still assigned to the elastic IP address:
Screen Shot 2012-12-11 at 12.54.25

One Important Note: As long as an Elastic IP address is associated with a running instance, there is no charge for it. However an address that is not associated with a running instance costs $0.01/hour. This prevents users from ‘reserving’ addresses while they are not being used.

Published at DZone with permission of its author, Eric Genesky.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)