Skip to content

Instantly share code, notes, and snippets.

@thomasbiddle
Created December 24, 2013 00:50
Show Gist options
  • Save thomasbiddle/8107195 to your computer and use it in GitHub Desktop.
Save thomasbiddle/8107195 to your computer and use it in GitHub Desktop.
This will revoke 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 "Revoking access for ${IP_ADDRESS}/32 to all ports on ${GROUP}/${REGION}."
ec2-revoke ${GROUP} --region ${REGION} -p -1 -s ${IP_ADDRESS}/32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment