Over a million developers have joined DZone.
Platinum Partner

Assign a Fixed IP to an AWS EC2 Instance

· Cloud Zone

The Cloud Zone is brought to you in partnership with Iron.io. Discover how Microservices have transformed the way developers are building and deploying applications in the era of modern cloud infrastructure.

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.

The Cloud Zone is brought to you in partnership with Iron.io. Learn how to build and test their Go programs inside Docker containers.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}