Skip to content

Instantly share code, notes, and snippets.

@thomasbiddle
Created December 24, 2013 00:49
Show Gist options
  • Save thomasbiddle/8107184 to your computer and use it in GitHub Desktop.
Save thomasbiddle/8107184 to your computer and use it in GitHub Desktop.
This will add your current IP address to the security group of choice. Assumes EC2 tools are on your PATH.
#!/bin/bash
# Initialize our own variables:
GROUP="default"
REGION="ap-northeast-1"
# Get our real public IP.
IP_ADDRESS=`curl ifconfig.me --silent`
while getopts "r:g:" opt; do
case "$opt" in
g)
GROUP=$OPTARG
;;
r) REGION=$OPTARG
;;
esac
done
echo "Adding access for ${IP_ADDRESS}/32 to all ports on ${GROUP}/${REGION}."
ec2-authorize ${GROUP} --region ${REGION} -s ${IP_ADDRESS}/32 -p -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment