You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何临时切换AWS CLI配置文件?(含v1/v2版本适配方案)

Fixing AWS CLI Profile Switching Not Working

I ran into this exact gotcha not too long ago—turns out the environment variable you use to switch profiles depends entirely on which AWS CLI version you're running!

When you tried export AWS_PROFILE=user2 and it didn't take effect, that's probably because you're using AWS CLI v1 instead of v2. Here's the correct command for each version:

  • For AWS CLI v1: You need to set the AWS_DEFAULT_PROFILE environment variable to switch profiles:
    export AWS_DEFAULT_PROFILE=user2
    
  • For AWS CLI v2: The AWS_PROFILE variable works directly, so your original command will work as expected:
    export AWS_PROFILE=user2
    

To make sure the switch was successful, you can verify the current authenticated identity with this command:

aws sts get-caller-identity

内容的提问来源于stack exchange,提问作者James Shapiro

火山引擎 最新活动