41

I have the aws cli installed on my macbook. I updated the version last week and since then it seems like it ignores the AWS_PROFILE environment variable? Has anyone encountered this? I have to add --profile to every statement now to make it go towards the profile I prefer.

Does anyone know what could be wrong or how I should troubleshoot it?

6
  • 4
    It is likely you have AWS_DEFAULT_PROFILE set which overrides AWS_PROFILE. Unset AWS_DEFAULT_PROFILE and try. Commented Apr 23, 2018 at 22:52
  • Sadly, same problem exists after unsetting that variable Commented Apr 26, 2018 at 11:35
  • I also have this problem. Trying to figure it out. Did you find a fix? Commented May 3, 2018 at 12:37
  • Not yet, I haven't used the CLI for a few days so I haven't had time to troubleshoot Commented May 8, 2018 at 11:35
  • I have the same issue. I had to specify --profile for every aws cli. Commented Jun 21, 2018 at 0:39

4 Answers 4

75

As per this link: AWS CLI environment variables Precedence

If AWS_PROFILE environment variable is set and the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are set, then the credentials provided by AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY will override the credentials located in the profile provided by AWS_PROFILE.

You have to unset both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY and set AWS_PROFILE instead then it should work correctly.

unset AWS_ACCESS_KEY_ID unset AWS_SECRET_ACCESS_KEY export AWS_PROFILE=[profile-name-here] 
Sign up to request clarification or add additional context in comments.

Comments

16

This looks like a bug to me.

Check my setup when I have nothing set for profile:

15278-gmcdaid:~ gmcdaid$ aws configure list Name Value Type Location ---- ----- ---- -------- profile <not set> None None 

Now, set the env var:

15278-gmcdaid:~ gmcdaid$ export AWS_PROFILE=foo 

Check setup again:

15278-gmcdaid:~ gmcdaid$ aws configure list Name Value Type Location ---- ----- ---- -------- profile foo manual --profile 

You can see that when AWS_PROFILE is set, the cli is set to use the manual switch for the profile, not the env var.

I installed the aws-cli around the same time you make this post.

5 Comments

Interesting, but it still sets the profile to foo, so it works for you anyway?
I opened an issue with the developers. Seems AWS_PROFILE is ignored if AWS_SECRET_ACCESS_KEY and AWS_ACCESS_KEY_ID are set. github.com/aws/aws-cli/issues/3304
Mine is working now :) I doublechecked my variables and I only set my variable as a shell variable and not as an environment variable. When I did that it started working
Still not working for me, with either Env of Shell vars. Could you provide any more detail or examples?
I didn't do much. I am using fish so I type: "set -xg AWS_PROFILE myprofile". Optionally use -U as well to set it everywhere. Then "env" displays the variable and aws configure list works as expected
13

I was only setting the AWS_PROFILE as a shell variable and not as a environment variable. After setting is as an environment variable everything worked as expected.

1 Comment

I always set AWS_PROFILE as an env variable but still the same issue.
8

Just re-state in another words and clean commands:

Run set | grep AWS, if you see any credentials there then AWS_PROFILE will be ignored

If you set the variable just as

AWS_PROFILE=boo

it won't work. Export it instead:

export AWS_PROFILE=boo

Or use env

env AWS_PROFILE=boo aws s3 ...

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.