This repository contains the files required to set up our Terraform infrastructure.
This block should be included in any other Terraform code that we run:
terraform {
backend "s3" {
bucket = "km-tf-state"
dynamodb_table = "terraformLock"
key = "<project-name>"
region = "us-east-1"
}
}
Note that <project-name>
should be unique across all projects that use this bucket.
The main objective of this module is to create an S3 bucket where we can store Terraform state for other projects.
terraform apply
If you make changes, make sure the Usage block is still up to date.
This module contains the code to provision the infrastructure used for other Terraform code. Because of this, we have to store its state in this repository. This means that no sensitive information should be used in this repository.
Making a change should create a new .tfstate
file that should be commited along with code changes.
While the Terraform code in this repository is fairly simple, there are a few notable items:
- We enabled versioning of the S3 bucket so that errors that corrupt a
.tfstate
file are fairly easy to recover from. - We create a DynamoDB table that allows Terraform to use a locking mechanism when applying changes. This is important if there is the possiblity of multiple users running
terraform apply
at the same time.
This project is licensed under the MIT License. See the LICENSE file for more information.
Chathan Driehuys (chathan@knowmetools.com)