Skip to content

Instantly share code, notes, and snippets.

@qtangs
qtangs / terraform_state_cloudformation_template.yml
Created November 21, 2020 13:12
CloudFormation Template for creating S3 bucket and DynamoDB table to hold Terraform state and locks
AWSTemplateFormatVersion: 2010-09-09
Description: >
Template for creating S3 bucket and DynamoDB table to hold Terraform state and locks
Validate: aws cloudformation validate-template --template-body file://terraform_state.yml
Deploy: aws cloudformation create-stack --region us-east-1 --stack-name Terraform-State-Resources --enable-termination-protection --template-body file://terraform_state.yml --parameters ParameterKey=TerraformStateBucketPrefix,ParameterValue=terraform-state ParameterKey=TerraformStateLockTableName,ParameterValue=terraform-state-locks
Parameters:
TerraformStateBucketPrefix:
Type: String
Default: terraform-state
Description: A prefix for S3 bucket name, account id will be added to ensure global uniqueness