Steps to reproduce the issue
AWS CLI Import Command run sucessfully
$ aws configure import --csv file:///Users/XYZ/Downloads/credentials.csv
Successfully imported 1 profile(s)
Profile mytestiamuser listed sucessfully
$ aws configure list-profiles
default
mytestiamuser
But when I try to run any command, it's failing due to below error? This is supposed to pick default region?
$ aws ec2 describe-regions --profile mytestiamuser
You must specify a region. You can also configure your region by running "aws configure".
$ aws configure --profile mytestiamuser
AWS Access Key ID [****XXXXX]:
AWS Secret Access Key [****XXXX]:
Default region name [None]:
Default output format [None]:
$ cat ~/.aws/config
[default]
region = us-west-2
After manually configuring the region, it's working as expected
$ aws configure --profile mytestiamuser
AWS Access Key ID [****XXXX]:
AWS Secret Access Key [****XXX]:
Default region name [None]: us-west-2
Default output format [None]:
$ aws ec2 describe-regions --profile mytestiamuser
{
"Regions": [
{
"Endpoint": "ec2.ap-south-1.amazonaws.com",
"RegionName": "ap-south-1"
},
So look like aws cli v2 is not picking the default region?
To be clear, the cli does not take values from the default
profile if they are not present in the profile you are using. If you set the AWS_DEFAULT_REGION
environment variable, that will be used regardless of profile.
I think it would be reasonable to offer some way for the import command to set regions, either by having --region
set the region for all imported profiles or asking for each. We should probably also put a warning in the output if you don't do that.
So you can always set the environment variable as part of the command, eg.:
AWS_DEFAULT_REGION=eu-west-1 aws xxxxx
Most helpful comment
To be clear, the cli does not take values from the
default
profile if they are not present in the profile you are using. If you set theAWS_DEFAULT_REGION
environment variable, that will be used regardless of profile.I think it would be reasonable to offer some way for the import command to set regions, either by having
--region
set the region for all imported profiles or asking for each. We should probably also put a warning in the output if you don't do that.