Last active
December 24, 2017 22:21
-
-
Save QROkes/d9fcfb26c2890bd15935 to your computer and use it in GitHub Desktop.
Automatically associate an elastic IP to an EC2 instance.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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=https://ec2.us-east-1.amazonaws.com | |
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 http://169.254.169.254/latest/meta-data/instance-id` | |
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