Skip to content

Securely Manage Your Infrastructure as Code (IaC) State with S3 Backend in AWS

License

Notifications You must be signed in to change notification settings

michael-ortiz/terraform-aws-s3-terraform-state

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS S3 Terraform State

Introduction

This is a public and open source module that allows you to create all the necesary AWS Infrastructure to have your Terraform state stored and encrypted in S3.

Read more on how to hook this up with your current Terraform project:

https://developer.hashicorp.com/terraform/language/settings/backends/s3

Example Usage

To use this module, place this code in your Terraform:

module "s3_terraform_state" {
  source  = "michael-ortiz/s3-terraform-state/aws"
  version = "~> 1.0"

  # Optional Bucket Names to store state in multiple buckets
  state_bucket_names = ["MY_S3_STATE_BUCKET_NAME"]

  # Optional DynamoDB Lock Name
  state_lock_table_name = "MY_S3_STATE_BUCKET_NAME"
}

Requirements

No requirements.

Providers

Name Version
aws n/a

Modules

No modules.

Resources

Name Type
aws_dynamodb_table.state_lock resource
aws_s3_bucket.state_bucket resource
aws_s3_bucket_server_side_encryption_configuration.state_bucket resource
aws_s3_bucket_versioning.state_bucket resource
aws_caller_identity.current data source

Inputs

Name Description Type Default Required
state_bucket_names A list of S3 bucket to create to store terraform state list(string) null no
state_lock_table_name The name of the DynamoDB table to create to store Terraform state lock string null no

Outputs

Name Description
state_bucket_names The names of the S3 buckets that store Terraform state
state_lock_table_name The name of the DynamoDB table that stores Terraform state lock