Taras Kuzyk
Taras Kuzyk

Reputation: 21

AWS CLI "aws configure" doesn't switch me to a new account

I am using a Windows 11 machine. I run aws configure, enter my access and secret keys, and am able to confirm that they are saved inside ~./aws/credentials.

However, when I run aws sts get-caller-identity, it shows that I am still logged into my old account. What could be causing this behaviour?

Upvotes: 0

Views: 1100

Answers (1)

Taras Kuzyk
Taras Kuzyk

Reputation: 21

After a lot of agony, it turned out that AWS CLI takes the environment variables first, and not the ~./aws/credentials config file. And since aws configure only updates said file, I was stuck updating something that was being overridden by default.

After deleting the environment variables starting with AWS_, everything works as expected.

Note that using profiles if you have your keys in your env will not work as expected either, and you will always be stuck on the profile configured in your environment variables.

Upvotes: 2

Related Questions