脚本宝典收集整理的这篇文章主要介绍了[DevOps] Terraform Remote State Management,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
In order to maintain your tfstate file properly, you MUST have versioning enabled on your S3 bucket.
Here is the code I used to create the backend.tf
file. You'll need to update it with the name of your S3 bucket and the path to your terraform.tfstate
file.
terraform {
backend "s3" {
bucket = "<Name of your S3 bucket>"
key = "<Path To Your terraform.tfstate file>"
region = "us-east-1"
}
}
Here is the code for terraform.tf used to create the S3 backend. You can model yours off my example, or be creative and create your own- just make sure you destroy any infrastructure you create!
provider "aws" {
access_key = "<Your Access Key>"
secret_key = "<Your Secret Key>"
region = "us-east-1"
}
resource "aws_instance" "Backend" {
count = "2"
ami = "ami-0323c3dd2da7fb37d"
instance_type = "t2.micro"
}
Save your backend.tf file
with your terraform.tf
(or main.tf
file) in a working directory under your Terraform root directory.
以上是脚本宝典为你收集整理的[DevOps] Terraform Remote State Management全部内容,希望文章能够帮你解决[DevOps] Terraform Remote State Management所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。