cbp*_*cbp 2 powershell amazon-web-services aws-cli
我在这里做错了什么?
我的 %UserProfile%.aws\config 文件如下所示:
[profile foo]
output = json
region = us-east-1
Run Code Online (Sandbox Code Playgroud)
我的 %UserProfile%.aws\credentials 文件如下所示:
[foo]
aws_access_key_id = BAOAIGKMPRBTLBNOSCZQ
aws_secret_access_key = OcML0LadbbD3Nt+PmAlhzNTmoS6Xx9M3M6DkBx4m
Run Code Online (Sandbox Code Playgroud)
所以没有配置默认配置文件:我只想为 Powershell 会话设置。
在 Powershell 中,我运行:
set AWS_PROFILE=foo
Run Code Online (Sandbox Code Playgroud)
然后我尝试执行 cli 命令,但它说找不到凭据:
PS D:\> aws ec2 describe-instances
You must specify a region. You can also configure your region by running "aws configure".
PS D:\> aws ec2 describe-instances --region us-east-1
Unable to locate credentials. You can configure credentials by running "aws configure".
Run Code Online (Sandbox Code Playgroud)
啊,我发现在 Powershell 中您不能使用该set命令设置环境变量。(旁白:我想知道当您使用该set命令时 Powershell 认为它在做什么......它没有给出错误消息)。
正确的方法是:
$env:AWS_PROFILE="foo"
Run Code Online (Sandbox Code Playgroud)