繁体   English   中英

Terraform、AWS 和 STS 请求中包含的安全令牌无效

[英]Terraform, AWS and STS The security token included in the request is invalid

我正在尝试使用 terraform 来启动与 AWS 的连接以创建基础设施。 如果我运行 aws configure sso,我可以默认登录到 eu-west-2 并在庄园周围移动,然后使用 terraform 应用,aws 部分如下:

provider "aws" {
  region = "eu-west-2"
  shared_credentials_file = "~/.aws/credentials"
  profile = "450694575897_ProdPS-SuperUsers"
}

Terraform 报告:错误:错误使用凭据获取帐户 ID:错误调用 sts:GetCallerIdentity: InvalidClientTokenId:请求中包含的安全令牌无效。 │ 状态码:403,请求id:5b8be53d-253d-4c48-8568-ad78be14115f

设置了以下变量:

AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY

如果我跑

aws sts get-session-token --region=us-west-2 

我明白了

An error occurred (InvalidClientTokenId) when calling the GetSessionToken operation: The security token included in the request is invalid.

当我尝试通过terraform cloud进行部署时,我遇到了同样的问题。

您可能正在使用deletedinactiveold key ,以确保:

1- 尝试转到您帐户页面上的安全凭证:单击右上角的您的姓名 -> My security credentials

2- 检查您在凭据中设置的密钥是否已删除或仍然存在。

2.2- 如果它被删除,创建一个新密钥并使用它。

3- 如果您的钥匙还在,请检查它是否active

我解决了以下问题:

$: aws configure
enter the access key:
enter the secret key:
select default region:
select default format[none/json]:

在您的 main.tf 文件中添加如下所示的配置文件

provider "aws" {
  region  = "eu-west-2"
  profile="xxxuuzzz"

}

暂无
暂无

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

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