使用后端在 S3 中存储 Terraform 状态
Terraform state storing in S3 using backend
我已经创建了 S3 存储桶和 Dynamodb 来存储 Terraform 状态文件并启用锁。
现在我正在尝试使用 terraform init 进行初始化,出现以下错误。请找到 backend.tf 和 main.tf 文件(我用这两个文件将状态文件存储到 s3 存储桶中)
正在初始化后端...
错误:找不到 AWS 提供商的有效凭证来源。
请参阅 https://terraform.io/docs/providers/aws/index.html 了解更多信息
为 AWS 提供商提供凭证
注意:我使用相同的访问密钥和秘密访问密钥创建 S3 存储桶和 DynamoDB。(创建用户并向该用户提供管理员访问权限)
###########
猫 main.yml
提供商“aws”{
access_key = "Access_Key_Here"
secret_key = "Secret_key_here"
region = "us-east-1"
}
资源“aws_instance”“示例”{
ami = "ami-2757f631"
instance_type = "t2.micro"
}
##########
猫backend.tf
地形{
backend "s3" {
bucket = "bucket_name_here"
key = "terraform.tfstate"
dynamodb_table = "table_name_here"
region = "us-east-1"
}
}
有人可以帮忙吗?
我建议导航(在终端中)到您的 terraform 脚本所在的文件夹并执行命令“aws configure”(https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html)
然后输入您的信誉。
希望这对您有所帮助,祝您好运。
我已经创建了 S3 存储桶和 Dynamodb 来存储 Terraform 状态文件并启用锁。
现在我正在尝试使用 terraform init 进行初始化,出现以下错误。请找到 backend.tf 和 main.tf 文件(我用这两个文件将状态文件存储到 s3 存储桶中)
正在初始化后端...
错误:找不到 AWS 提供商的有效凭证来源。 请参阅 https://terraform.io/docs/providers/aws/index.html 了解更多信息 为 AWS 提供商提供凭证
注意:我使用相同的访问密钥和秘密访问密钥创建 S3 存储桶和 DynamoDB。(创建用户并向该用户提供管理员访问权限)
########### 猫 main.yml
提供商“aws”{
access_key = "Access_Key_Here"
secret_key = "Secret_key_here"
region = "us-east-1"
}
资源“aws_instance”“示例”{
ami = "ami-2757f631"
instance_type = "t2.micro"
}
##########
猫backend.tf
地形{
backend "s3" {
bucket = "bucket_name_here"
key = "terraform.tfstate"
dynamodb_table = "table_name_here"
region = "us-east-1"
}
}
有人可以帮忙吗?
我建议导航(在终端中)到您的 terraform 脚本所在的文件夹并执行命令“aws configure”(https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html) 然后输入您的信誉。 希望这对您有所帮助,祝您好运。