【问题标题】:Why I am receiving aws ExpiredToken: The security token included in the request is expired?为什么我收到 aws ExpiredToken:请求中包含的安全令牌已过期?
【发布时间】:2021-02-03 00:44:46
【问题描述】:

我正在尝试测试一个 github 项目 - https://github.com/charlottemach/cross-account-aws-iam-roles 关于 aws 上的 terraform 和两个帐户,假设的角色。我在本地从我的电脑运行这个 terraform 脚本。当然我在 .aws\config 中添加了两个配置文件

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

[profile prod]
region = eu-north-1
output = json

[profile utils]
region = eu-north-1
output = json

和 .aws\凭据

[default]
aws_access_key_id = xxx
aws_secret_access_key = xxxx

[prod]
aws_access_key_id = xxx
aws_secret_access_key = xxxx

[utils]
aws_access_key_id = xxx
aws_secret_access_key = xxxx

问题是我收到错误消息。我找不到任何解决此问题的方法。首先我运行 terraform init 它执行成功,现在我运行 terraform plan 并且出现以下错误:

terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.


Error: error configuring Terraform AWS Provider: error validating provider credentials: error calling 
sts:GetCallerIdentity: ExpiredToken: The security token included in the request is expired
    status code: 403, request id: xxxx-xxx



Error: error configuring Terraform AWS Provider: error validating provider credentials: error calling 
sts:GetCallerIdentity: ExpiredToken: The security token included in the request is expired
    status code: 403, request id: xxxx-xxx

【问题讨论】:

    标签: amazon-web-services terraform


    【解决方案1】:

    Terraform 将环境变量优先于配置文件。检查以确保您的环境中没有设置 AWS_SECURITY_TOKEN 或 AWS_ACCESS_KEY_ID。

    如果这两个都缺失,请运行env TF_LOG=TRACE terraform plan。这将提供非常详细的日志,并让您知道您正在提取哪些身份验证信息。

    【讨论】:

      猜你喜欢
      • 2016-06-11
      • 2020-01-11
      • 2015-07-06
      • 2018-04-09
      • 1970-01-01
      • 2021-11-02
      • 1970-01-01
      • 1970-01-01
      • 2020-12-24
      相关资源
      最近更新 更多