Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using a custom bash script to spin up/down EC2 instances as needed. The script creates the instance similar to: knife ec2 server create --config .chef/knife.rb with a few other parameters. It creates the instance fine but I want to be able to assign my elastic ip to the current active instance.

Short of sending the output to a text file, parsing the output for the IP and instance name, and then running ec2-associate-address -i $instancename $ipaddress is there a good way to do this programmatically?

I believe I'm over thinking this.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

You might want to look at the Opscode "AWS" cookbook which contains a LWRP for attaching elastic IPs to AWS instances.

share|improve this answer
add comment

Found two answers. You can script your own setup using the Fog ruby gem:

gem install fog

Or follow the tutorial here with Perl:

http://www.krzywanski.net/archives/592

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.