Created
March 9, 2018 17:59
-
-
Save gambtho/57602c06deef36c37f2b64b2d04842c9 to your computer and use it in GitHub Desktop.
EC2 access to AWS creds and EIP
This file contains hidden or 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
apt-get install python-pip jq -y | |
pip install --upgrade awscli | |
aws_access_key_id=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/$${instance_profile} | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g'` | |
aws_secret_access_key=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/$${instance_profile} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'` | |
INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) | |
aws ec2 associate-address --instance-id $${INSTANCE_ID} --allocation-id ${ALLOCATION_ID} --allow-reassociation --region us-east-1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment