amazon-web-services - 为什么我收到 aws ExpiredToken:请求中包含的安全令牌已过期?
问题描述
我正在尝试测试一个 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\credentials
[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
解决方案
Terraform 将环境变量优先于配置文件。检查以确保您的环境中没有设置 AWS_SECURITY_TOKEN 或 AWS_ACCESS_KEY_ID。
如果这两个都缺失,请运行env TF_LOG=TRACE terraform plan
. 这将提供非常详细的日志,并让您知道您正在提取哪些身份验证信息。
推荐阅读
- time-series - 在 Tsay 的平均代码中将虚拟变量放在 GARCH 中的哪里并获得输出?
- ruby-on-rails - 出于测试目的,尝试从一个 actionmailer 方法返回所有已发送电子邮件的数组
- opencv - 如何获得干净的视差图和干净的深度图
- javascript - 如何使用 Vanilla JavaScript 或 JQuery 实现受控组件(在 ReactJS 中)
- file - 上传文件到 Telegram Server 的方法
- ruby-on-rails - 如果只配置了一个主机,Rails 是否会自动找出 MongoDB 副本集中的主节点?
- java - 解决此错误错误,找不到符号方法 makeHttpRequest(String,String,List
) - google-cloud-platform - 使用 AI Platform 将图像分割模型部署到生产环境:HTTP 请求 500 错误
- reactjs - 关于firebase + react的教程有问题
- php - PHP 致命错误:“无法在写入上下文中使用函数返回值”