【发布时间】:2021-09-26 10:09:06
【问题描述】:
尝试将我的状态文件存储在 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.
main.tf:
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" {}
【问题讨论】:
标签: amazon-web-services amazon-s3 terraform terraform-provider-aws