首页 > 解决方案 > 在没有 --profile 标志的情况下,每个 aws 命令都会失败并出现不同的错误

问题描述

免责声明:我确实将变量AWS_PROFILE设置为default并且 echo $AWS_PROFILE 确实 return default

但是,如果我不传递 --profile 标志,我的简单 aws 命令将失败。

例如,

如果我这样做aws2 s3 ls,那么它会失败并出现错误:An error occurred (InvalidToken) when calling the ListBuckets operation: The provided token is malformed or otherwise invalid.

当我这样做时aws2 ec2 describe-instances,它失败并出现错误An error occurred (AuthFailure) when calling the DescribeInstances operation: AWS was not able to validate the provided access credentials

即使消息不同,根本问题是相同的。如果我这样做,aws2 s3 ls --profile default那么它工作正常,与aws2 ec2 describe-instances命令相同。

即使我确实AWS_PROFILE设置了,我也不知道如何不需要 --profile 标志。

我的凭据文件如下所示:

[default]
aws_access_key_id = AKIA****
aws_secret_access_key = VpR***

我的配置文件如下所示:

[default]
region = us-west-1
output = json

我设置了以下两个环境变量:

AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY。此外,我已经回显了他们的值,并确保这些值与凭证文件中的值完全相同。

有任何想法吗?

标签: amazon-web-services

解决方案


  • 用于unset AWS_PROFILE删除配置文件标记。

  • 运行aws configure以更新凭据

  • 确保您的机器时间正确。


推荐阅读