Skip to content

Instantly share code, notes, and snippets.

@eerien
Created January 28, 2014 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eerien/2939c84ba9c1d191c6b0 to your computer and use it in GitHub Desktop.
Save eerien/2939c84ba9c1d191c6b0 to your computer and use it in GitHub Desktop.
Code snippet to recognize or determine region placed itself by using 169.254.169.254 on AWS.
AZ=`curl http://169.254.169.254/2012-01-12/meta-data/placement/availability-zone 2> /dev/null`
if [[ $AZ =~ 'us-east-1' ]]; then # N. Virginia
elif [[ $AZ =~ 'us-west-2' ]]; then # Oregon
elif [[ $AZ =~ 'us-west-1' ]]; then # N. California
elif [[ $AZ =~ 'eu-west-1' ]]; then # Ireland
elif [[ $AZ =~ 'ap-southeast-1' ]]; then # Singapore
elif [[ $AZ =~ 'ap-northeast-1' ]]; then # Tokyo
elif [[ $AZ =~ 'ap-southeast-2' ]]; then # Sydney
elif [[ $AZ =~ 'sa-east-1' ]]; then # Sao Paulo
else # Others
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment