Skip to content

Instantly share code, notes, and snippets.

@rosstimson
Created July 3, 2015 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rosstimson/ad2b79a78159bd80ffeb to your computer and use it in GitHub Desktop.
Save rosstimson/ad2b79a78159bd80ffeb to your computer and use it in GitHub Desktop.
EC2 tag version of Bash installed.
#!/usr/bin/env bash
EC2_INSTANCE_ID="`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id`"
EC2_REGION="`wget -q -O - http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/.$//g'`"
if ! type "aws" > /dev/null; then
if ! type "pip" > /dev/null; then
easy_install pip
fi
pip install awscli
fi
mkdir ~/.aws
cat << EOF >> ~/.aws/config
[profile tag]
output = json
region = $EC2_REGION
aws_access_key_id = $TAG_WRITE_ACCESSKEY
aws_secret_access_key = $TAG_WRITE_SECRETKEY
EOF
aws --profile=tag ec2 create-tags --resources $EC2_INSTANCE_ID --tags Key=bash,Value=`rpm -qa | grep bash`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment