amazon-web-services - Terraform 在配置 S3 后端时出错
问题描述
尝试将我的状态文件存储在 s3 存储桶中,但在尝试“Terraform init”时出现此错误:
- 确保我的 aws 凭据没有“/# $ ..”
error configuring S3 Backend: error validating provider credentials:
error calling sts:GetCallerIdentity:
InvalidClientTokenId: The security token included in the request is invalid.
主文件:
provider "aws" {
region = var.region
access_key = var.acc_key
secret_key = var.sec_key
}
terraform {
backend "s3" {
bucket = "mybucket-terra-prac"
key = "terraform.tfstate"
region = "eu-central-1"
}
}
resource "aws_instance" "web" {
ami = var.ami
instance_type = "t2.large"
associate_public_ip_address=true
key_name = var.public_key
tags = {
Name = var.ec2_name
}
}
我在 variables.tf 文件中的变量(具有类型和默认值):
variable "acc_key" {}
variable "sec_key" {}
variable "public_key" {}
variable "ami" {}
解决方案
尝试执行aws sts get-caller-identity
命令,看看您使用的是正确的凭据。
推荐阅读
- python - 尝试训练网络输出:max_pooling2d 从 1 中减去 2 导致的负维度大小
- amazon-web-services - AWS 中的“CharacterSetSettings”
- swift - 根据字段名称过滤对象数组
- python - 如何在 xy 图上绘制循环图
- javascript - 太多同时调用 Google 脚本
- javascript - 如何从 javascript 中的值获取字符串文字(字符数组?)?
- python - pytest django 需要 db 访问才能进行不访问 db 的测试
- powershell - 使用 Move-ADObject 到组织单位时收到错误
- react-native - 卡在启动画面上
- r - 计算数据框中每一列的特定值跟随另一个特定值的次数