简体   繁体   English

AWS CLI“aws configure”不会将我切换到新账户

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

I am using a Windows 11 machine.我使用的是 Windows 11 机器。 I run aws configure , enter my access and secret keys, and am able to confirm that they are saved inside ~./aws/credentials.我运行aws configure ,输入我的访问密钥和密钥,并能够确认它们保存在~./aws/credentials.

However, when I run aws sts get-caller-identity , it shows that I am still logged into my old account.但是,当我运行aws sts get-caller-identity时,它显示我仍然登录到我的旧帐户。 What could be causing this behaviour?是什么导致了这种行为?

After a lot of agony, it turned out that AWS CLI takes the environment variables first, and not the ~./aws/credentials config file.经过大量的痛苦之后,事实证明 AWS CLI 首先获取环境变量,而不是~./aws/credentials配置文件。 And since aws configure only updates said file, I was stuck updating something that was being overridden by default.而且由于aws configure仅更新所述文件,因此我无法更新默认情况下被覆盖的内容。

After deleting the environment variables starting with AWS_ , everything works as expected.删除以AWS_开头的环境变量后,一切正常。

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.请注意,如果您的环境中有密钥,则使用配置文件也不会按预期工作,并且您将始终停留在环境变量中配置的配置文件上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM