Skip to content

Instantly share code, notes, and snippets.

@vancluever
Last active May 15, 2018 15:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vancluever/2ee0cbea6c6b41993581 to your computer and use it in GitHub Desktop.
Save vancluever/2ee0cbea6c6b41993581 to your computer and use it in GitHub Desktop.
AWS region/availability zone one-liners (from running instance)
# One can get the availability zone easily from within an AWS EC2 instance:
AVAILABILITY_ZONE=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone`
echo $AVAILABILITY_ZONE
# Take that a step further, and you can get the region easily by just chopping
# the last character off.
REGION=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed -e 's/.$//g'`
echo $REGION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment