Code Monkey home page Code Monkey logo

terraform-aws-state-backend's Introduction

terraform-aws-state-backend

This is a simple terraform module to bootstrap the creation of necessary resources to have a shared AWS-based S3 backend.

It creates few resources, but opinions come included

  • A KMS key with rotation enabled
  • An S3 bucket with SSE (using the above key), versioning, and private ACLs.
  • A DynamoDB table to be used to lock the state file and avoid multiple concurrent deploys

Example Usage

provider "aws" {
  region = "us-east-2"
}

module "aws_backend_resources" {
  source        = "git::github.com/sbogacz/terraform-aws-state-backend"
  bucket_prefix = "my-prefix"

  tags = {
    Type        = "Infrastructure"
    Description = "Resources to manage TF State"
  }
}

output "sample_usage" {
  value = "${module.aws_backend_resources.sample_usage}"
}

Sample Usage

The last line in the example is simply to produce a starter that you can use in the subsequent Terraform projects that will leverage this common backend.

If you follow the pattern above to use this module, you could also print the output with terraform output sample_usage which would yield something like:

terraform {
  backend "s3" {
      bucket = "my-prefix-terraform"
      region = "us-east-2"
      dynamodb_table = "my-prefix-state-file-lock"
      key = "example/path/to/state"
  }
}

Which you could copy and paste into some other Terraform main.tf

terraform-aws-state-backend's People

Contributors

sbogacz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.