undefined
undefined

Reputation: 5330

Is there a way to associate an elastic IP address with EC2 instance on startup?

Hi I am developing the code to start an instance of an EC2 image on Amazon Web Services, there are 2 steps

1) start the instance 2) allocate our Elastic IP address to the started instance

Is there a way to carry out both of these in a single command?

I will be running a .bat file to start the instance, and then when the instance is running I will use the REST query API to call AssociateAddress. I'm not sure yet how best to determine when the started instance changes from pending to running other than making periodic calls to it. Am I able to associate an IP address to a pending instance?

Stephen

Upvotes: 2

Views: 2896

Answers (2)

Gary Richardson
Gary Richardson

Reputation: 16441

Yes, you can assign the IP to the pending instance. It's handled from the firewalls and not your instance, so it doesn't need to be running to make the change. Your instance never actually knows about the Elastic IP.

Upvotes: 1

gareth_bowles
gareth_bowles

Reputation: 21130

Sure, you'd need to add a startup script to your EC2 instance that runs the allocate-address command at boot time to do the association of the elastic IP. Here's a tutorial on adding startup / shutdown scripts to an EC2 instance.

Upvotes: 1

Related Questions