Rolling Windows and Sticky Bytes

<tagline type="clever"/>

Automating Elastic IP Assignment Redux

on 2012-07-14

As a follow-up to my previous post on Automating Elastic IP Assignment, I went back and installed the package from my distro’s repository and updated my script with the new binary locations. I’m using Ubuntu on my development instance so this post will be very Ubuntu-centric.

The ec2-api-tools package is in the multiverse repository which is not enabled by default on Ubuntu so before I could get started, I had to enable the multiverse repository as documented in the Ubuntu documentation on Repositories:

  1. Edit /etc/apt/sources.list
  2. Uncomment the four lines for the multiverse repository
  3. Run apt-get update to fetch the repository index

Once I had the multiverse repository enabled, installing the package was as easy as apt-get install ec2-api-tools. The package payload is deployed into /usr.

The updated elastic-ip script is below.

/etc/init.d/elastic-ip

#!/bin/bash

# Set environment variables
export JAVA_HOME=/usr

export EC2_HOME=/usr
export EC2_BIN=$EC2_HOME/bin

export EC2_PRIVATE_KEY=/root/.ec2/keyfile.pem
export EC2_CERT=/root/.ec2/certfile.pem

export EC2_URL=https://ec2.us-east-1.amazonaws.com

# Associate the elastic IP with the instance
$EC2_BIN/ec2-associate-address -i i-deadbeef 10.99.99.5

Leave a Reply

Your email address will not be published. Required fields are marked *