Created
January 28, 2014 07:10
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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