Using aws cli, what is best way to determine the current region

mckenzm picture mckenzm · Jul 10, 2015 · Viewed 24.5k times · Source

Interactively, I can use "aws configure" to change or see the default region. Is there a "pwd" like function, documented or not that allows me to determine or confirm the current region mid-script ? Even if AWS_DEFAULT_REGION is not defined ? I want a script to run under a number of profiles. I can scrape from aws configure list, but is there something neater ?

Answer

Jeshan Babooa picture Jeshan Babooa · Feb 1, 2017

aws configure get region will get you the current region at that point in your script.

If you are using a profile, then type aws configure get --profile $PROFILE_NAME.