Created
September 6, 2017 18:21
-
-
Save bitdivine/3ba095a791e914d19388919485867b17 to your computer and use it in GitHub Desktop.
Get the AWS region - either from the profile or, if running on an AWS instance, by looking up the instance metadata.
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
echo If the region is given in the environment: | |
echo $AWS_DEFAULT_REGION | |
echo If aws has been configured: | |
aws configure get region | |
echo If running on an aws instance, the availability zone is in the metadata and hence we have the region: | |
ec2metadata --availability-zone | sed -r 's/.$//g' | |
echo Equivalently: | |
curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed -r 's/.$//g' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment