繁体   English   中英

无服务器错误:请求中包含的安全令牌无效

[英]Serverless Error: The security token included in the request is invalid

当我键入 serverless deploy 时出现此错误:ServerlessError:请求中包含的安全令牌无效。

我必须在我的serverless deploy命令中指定 sls deploy --aws-profile ,如下所示:

sls deploy --aws-profile common

你能提供更多信息吗?

确保您在~/.aws/config~/.aws/credentials获得了正确的~/.aws/credentials 您可以通过运行aws configure来设置这些。 更多信息: https : //docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-quick-configuration

还要确保有问题的 IAM 用户具有附加的安全策略,允许访问您需要的一切,例如 CloudFormation。

在 AWS 中创建一个新用户(不要使用根密钥)。

在 AWS CodeCommit 的 SSH 密钥中,生成一个新的访问密钥。

复制值并运行:

serverless config credentials --overwrite --provider aws --key bar --secret foo

sls deploy

在此处输入图片说明

就我而言,它缺少无服务器文件中的localstack条目。 我有所有应该在里面的东西,但它都在custom里面(而不是custom.localstack )。

就我而言,我向提供程序添加了区域。 我想它不是从凭证文件中读取的。

provider:
  name: aws
  runtime: nodejs12.x
  region: cn-northwest-1

就我而言,多个凭据存储在~/.aws/credentials文件中。

无服务器正在选择默认凭据。

因此,我将新凭据保留在[default]并删除了以前的凭据。 这对我有用。

在此处输入图片说明

要从 AWS 运行 function,您需要使用 access_key_id 和 secret_access_key 配置 AWS,但如果您想在本地运行 function,则可能会出现此错误,以便使用此命令

sls invoke local -f functionName

它将在本地而不是在 aws 上运行 function

暂无
暂无

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

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