请求中包含的 aws sam 无效令牌无效

问题描述

我正在使用 aws sam 并尝试进行 sam 部署。我收到此错误

Error: Failed to create managed resources: An error occurred (InvalidClientTokenId) when calling the CreateChangeSet operation: The security token included in the request is invalid. 

我已经从 .aws 更改了我的凭据,并使用命令 aws configure 更改了它们。 当我尝试访问任何在线内容时(例如尝试将文件上传到 S3 存储桶),我也会收到错误消息。

Error: botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the UpdateItem operation: The security token included in the request is invalid.

有什么想法吗?

解决方法

如果您有多个且没有指定默认值,则需要检查您是否在 ~/.aws/credentials 文件中设置了 default 凭据 在共享凭据文件中加上您没有在您的环境中设置任何内容 sam cli 将失败并显示上述消息。

您使用此 this 文档来设置它们

,

当我收到“请求中的令牌无效”时,我的特定解决方案是:

  1. 我尝试使用与默认配置不同的配置文件,将默认配置更新为我想要运行的配置文件
  2. 根据需要使用默认设置启动“sam init”,从初始化到构建再到部署时不要进行更改。 文档说明为键设置 env var,但尚未尝试过。