【问题标题】:Serverless Error: The security token included in the request is invalid无服务器错误:请求中包含的安全令牌无效
【发布时间】:2019-04-20 01:27:02
【问题描述】:

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

【问题讨论】:

    标签: amazon-web-services amazon-iam serverless-framework serverless


    【解决方案1】:

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

    sls deploy --aws-profile common

    【讨论】:

      【解决方案2】:

      您能提供更多信息吗?

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

      还要确保相关 IAM 用户具有附加的安全策略,允许访问您需要的所有内容,例如 CloudFormation。

      【讨论】:

      • 一切都很好,似乎windows有问题,我下载了另一个控制台:“ubuntu bash for windows”并在该控制台中再次安装nodejs、npm和serverless,然后我创建了一个项目并输入“无服务器部署”,它就可以工作了
      【解决方案3】:

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

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

      复制值并运行:

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

      【讨论】:

        【解决方案4】:

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

        【讨论】:

          【解决方案5】:

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

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

          【讨论】:

            【解决方案6】:

            在我的例子中,多个凭据存储在 ~/.aws/credentials 文件中。

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

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

            【讨论】:

            • 希望这些凭据是假的,至于良好的做法,我们不应该与任何人分享 aws 秘密
            猜你喜欢
            • 2015-02-20
            • 1970-01-01
            • 1970-01-01
            • 2016-12-12
            • 2018-04-09
            • 2020-02-01
            • 2014-01-30
            • 2021-06-22
            • 1970-01-01
            相关资源
            最近更新 更多