0
votes

I have multiple profiles in my aws cofig files. when I try to use aws ec2 describe-instances --profile mfa it asks for region even though I have defined it in the config. Each time I have you use --region in my script.

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

~/.aws/credentials

    [default]
    aws_access_key_id = **********
    aws_secret_access_key = ***********
    [mfa]
    aws_access_key_id = ***********
    aws_secret_access_key = *********************
    aws_session_token = ******************
    [dev]
    aws_access_key_id = *****************
    aws_secret_access_key = ******************
    [comp]
    role_arn = arn:aws:iam::<accountnumber>:role/CrossAccountSignin
    source_profile = mfa

~/.aws/config

[default]
region = us-east-1
output = json
[mfa]
region = us-east-1
output = json
[dev]
region = us-east-1
output = json
1

1 Answers

3
votes

Set your config file as,

[profile mfa]
region = us-east-1
output = json

[profile dev]
region = us-east-1
output = json