zoukankan      html  css  js  c++  java
  • [DevOps] Terraform Remote State Management

    Demo Code

    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. 

  • 相关阅读:
    最近有点烦
    好累啊
    几招有效防电脑辐射
    发两张搞笑图片
    几招有效防电脑辐射
    English Study
    人脸识别方法(转载)
    小常识
    23、C++ Primer 4th 笔记,面向对象编程(1)
    18、C++ Primer 4th 笔记,复制控制
  • 原文地址:https://www.cnblogs.com/Answer1215/p/15350921.html
Copyright © 2011-2022 走看看