Terraform S3 后端与 DynamoDB 锁配置后端片段(`main.tf`)terraform {

backend "s3" {

bucket = "tf-state"

key = "prod/terraform.tfstate"

region = "us-east-1"

dynamodb_table = "tf-locks"

encrypt = true

}

}

资源创建(示意)aws s3api create-bucket --bucket tf-state --region us-east-1 --create-bucket-configuration LocationConstraint=us-east-1

aws dynamodb create-table --table-name tf-locks --attribute-definitions AttributeName=LockID,AttributeType=S --key-schema AttributeName=LockID,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5

初始化terraform init

总结S3+DynamoDB 后端提供远端状态与并发锁,提升团队协作与安全。

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部