Skip to content

Instantly share code, notes, and snippets.

@QROkes QROkes/rc.local
Last active Dec 24, 2017

What would you like to do?
Automatically associate an elastic IP to an EC2 instance.
# Please, enable "Multiverse" in /etc/apt/sources.list
# Add the AWS PPA - sudo apt-add-repository ppa:awstools-dev/awstools
# Update and then install - sudo apt-get update && sudo apt-get install ec2-api-tools
# Upload your AWS Credential (PEM files)
# Save this script in /etc/rc.local
export EC2_KEYPAIR=<name only-not the file name>
export EC2_URL=
export EC2_PRIVATE_KEY=/var/opt/ec2/<pk-filename.pem>
export EC2_CERT=/var/opt/ec2/<cert-filename.pem>
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/
export AWS_ACCESS_KEY=<Your AWS S3 access key>
export AWS_SECRET_KEY=<Your AWS S3 secret key>
instanceid=`/usr/bin/curl -s`
ec2-associate-address -i $instanceid <Your elastic IP>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.