我们一直在使用 s3 来保存状态文件,但这在 v0.9 中被破坏了,我似乎找不到一个简洁的文档来解决这个问题,感谢任何帮助
使用 v0.8
terraform remote config \
-backend=s3 \
-backend-config="bucket=tf-state" \
-backend-config="key=terraform.tfstate" \
-backend-config="region=eu-west-1" \
-backend-config="acl=bucket-owner-full-control" \
-backend-config="encrypt=1"
terraform remote pull
terraform get
terraform apply
terraform remote push
在 terraform 0.9 中,远程配置命令消失了,我尝试了以下操作,但它也没有将状态拉回或推回到 s3
terraform9x init \
-backend=true \
-backend-config="bucket=tf-state" \
-backend-config="key=terraform.tfstate" \
-backend-config="region=eu-west-1" \
-backend-config="acl=bucket-owner-full-control" \
-backend-config="encrypt=1" \
-get=true \
-input=false \
-force-copy
terraform9x remote pull
terraform9x get
terraform9x apply
terraform9x remote push
最佳答案
阻止远程状态在我们的代码中正确启动的一个问题是在我们的代码中使用 terraform required_version > 0.9.1:
terraform {
required_version = ">= 0.9.1"
backend "s3" {}
}
已提交错误 ( https://github.com/hashicorp/terraform/pull/12942 ),似乎已关闭,但根据评论,它仍然是一个悬而未决的问题: https://github.com/hashicorp/terraform/issues/12971
关于terraform v0.9 - s3 后端,语法问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43205222/