我对 terraform 很陌生,但我在尝试设置一个 terraform 后端以使用 S3 时遇到了困难。
初始化:
terraform init -backend-config="access_key=XXXXXXX" -backend-config="secret_key=XXXXX"
地形后端:
resource "aws_dynamodb_table" "terraform_state_lock" {
name = "terraform-lock"
read_capacity = 5
write_capacity = 5
hash_key = "LockID"
attribute {
name = "LockID"
type = "S"
}
}
resource "aws_s3_bucket" "bucket" {
bucket = "tfbackend"
}
terraform {
backend "s3" {
bucket = "tfbackend"
key = "terraform"
region = "eu-west-1"
dynamodb_table = "terraform-lock"
}
}
错误:
Error: error using credentials to get account ID: error calling sts:GetCallerIdentity: SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
status code: 403, request id: xxxx-xxxx
我真的很茫然,因为这些相同的凭据用于我的 Terraform 基础设施并且运行良好。AWS 上的 IAM 用户还具有 Dynamo 和 S3 的权限。
我是否应该告诉Terraform使用不同的身份验证方法?
删除 .terraform/并重试并真正仔细检查您的凭据。
我重新生成访问密钥和密码并且效果很好。