aws cli not honouring default region configuration

Viewed 1516

I have the default region set in ~/.aws/config file:

[default]
region=us-west-2

However, when I try describe-instances command for some specific profile it is failing with the following message:

$ aws ec2 describe-instances --profile my_profile
You must specify a region. You can also configure your region by running "aws configure".

Shouldn't it used the default profile configured in ~/.aws/config file? What am I missing here?

Output of aws configure list:

      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                <not set>             None    None
access_key     ******************** shared-credentials-file
secret_key     ******************** shared-credentials-file
    region                us-west-2      config-file    ~/.aws/config

Output of aws configure list --profile my_profile

      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                my_profile           manual    --profile
access_key     ******************** shared-credentials-file
secret_key     ******************** shared-credentials-file
    region                <not set>             None    None

p.s. new to AWS. pardon me if this is a very basic question.

1 Answers

You are using named profiles, by default default profile is used. Just like you configure default, you can/need to configure your profile.

aws configure --profile my_profile

It will prompt you to fill access key, secret access key, AWS Region, and output format as it is stated here

You can create additional configurations that you can refer to with a name by specifying the --profile option and assigning a name. The following example creates a profile named produser. You can specify credentials from a completely different account and Region than the other profiles.

Related