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. 

  • 相关阅读:
    pandas 的pd.cut()数据分箱
    pandas 的groupby()
    pandas 的DataFrame.apply()
    天池二手车_特征工程
    numpy简单的笔记
    python 面向对象编程的@property
    mybatis 复杂sql语句
    mybatis Lombok
    mybatis 获取 sqlSession
    mybatis @Param 注解
  • 原文地址:https://www.cnblogs.com/Answer1215/p/15350921.html
Copyright © 2011-2022 走看看