Skip to content

synapsestudios/terraform-aws-s3-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform S3 Backend Module

Terraform module which creates S3 backend resources on AWS.

Usage

Example of usage that does not utilize KMS encryption:

Non-KMS provisioning will default to AES256

module "s3_backend" {
  source = "github.com/synapsestudios/terraform-aws-s3-backend"

  bucket_prefix = "my-terraform-state"
  region = "us-west-2"

  tags = {
    Terraform = "true"
    Environment = "dev"
  }
}

Example of usage utilizing KMS encryption:

⚠️ Enabling KMS requires a list of principal ARNs that will be granted access to the KMS key. All users added to this will have full access over the provisioned key ⚠️

module "s3_backend" {
  source = "github.com/synapsestudios/terraform-aws-s3-backend"

  bucket_prefix = "my-terraform-state"
  region = "us-west-2"

  use_kms = true

  principal_arns = [
    "arn:aws:iam::123456789012:role/role-name",
    "arn:aws:iam::123456789012:role/role-name"
  ]

  tags = {
    Terraform = "true"
    Environment = "dev"
  }
}

Requirements

No requirements.

Providers

Name Version
aws n/a

Modules

No modules.

Resources

Name Type
aws_dynamodb_table.this resource
aws_kms_key.this resource
aws_s3_bucket.this resource
aws_s3_bucket.this-logs resource
aws_s3_bucket_logging.this resource
aws_s3_bucket_public_access_block.this resource
aws_s3_bucket_public_access_block.this-logs resource
aws_s3_bucket_server_side_encryption_configuration.this resource
aws_s3_bucket_server_side_encryption_configuration.this-logs resource
aws_s3_bucket_versioning.this resource
aws_iam_policy_document.kms_policy data source

Inputs

Name Description Type Default Required
name_prefix The name to give the bucket and Dynamo table where the statefile and locks will be stored (Must be 23 characters or less) string n/a yes
principal_arns List of ARNs to grant access to the KMS key (if use_kms is true) list(string) [] no
tags Tags to apply to the resources map(string) {} no
use_kms Whether to use KMS encryption or not bool false no

Outputs

Name Description
dynamo_table_name The name of the dynamoDB table
kms_key_id The provisioned KMS key id
s3_bucket_id The name of the s3 terraform backend bucket