https://github.com/byu-oit/terraform-aws-backend-s3
Terraform module that creates an S3 bucket and DynamoDB table for backend state files
https://github.com/byu-oit/terraform-aws-backend-s3
terraform-module tool
Last synced: over 1 year ago
JSON representation
Terraform module that creates an S3 bucket and DynamoDB table for backend state files
- Host: GitHub
- URL: https://github.com/byu-oit/terraform-aws-backend-s3
- Owner: byu-oit
- License: apache-2.0
- Created: 2019-11-27T21:27:35.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-07-14T17:37:51.000Z (almost 3 years ago)
- Last Synced: 2024-04-14T06:10:00.605Z (about 2 years ago)
- Topics: terraform-module, tool
- Language: HCL
- Size: 37.1 KB
- Stars: 2
- Watchers: 22
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Terraform AWS Backend S3
Terraform module that creates an S3 bucket and DynamoDB table for backend state files.
## Quickstart
This is one of the few modules that you can just run "as is" and then throw away the config and state.
```sh
git clone https://github.com/byu-oit/terraform-aws-backend-s3.git
cd terraform-aws-backend-s3/examples/simple
aws sso login
export AWS_PROFILE=my-account-profile
terraform init
terraform apply
cd ../../../
rm -rf terraform-aws-backend-s3
```
## Usage
```hcl
module "backend-s3" {
source = "github.com/byu-oit/terraform-aws-backend-s3?ref=v2.0.0"
}
```
Run `terraform apply` to create the S3 bucket and DynamoDB table for storing state files. Then add:
```hcl
terraform {
backend "s3" {
bucket = "terraform-state-storage-"
dynamodb_table = "terraform-state-lock-"
key = "my-cool-app.tfstate"
region = "us-west-2"
}
}
```
to configure your terraform backend to the newly created S3 bucket and DynamoDB table.
## Input
| Variable | Default | Description |
|---------------------|------------------------------------------|--------------------------------------------|
| bucket_name | terraform-state-storage- | S3 bucket name for state file storage |
| dynamodb_table_name | terraform-state-lock- | DynamoDB table name for state file locking |
## Output
| Name | Description |
|----------------|------------------------------------------------------------------------------------------------------------------------------------------------|
| s3_bucket | S3 bucket [object](https://www.terraform.io/docs/providers/aws/r/s3_bucket.html#attributes-reference) for terraform state storage |
| s3_bucket_name | Bucket name of the `s3_bucket` |
| dynamodb_table | DynamoDB Table [object](https://www.terraform.io/docs/providers/aws/r/dynamodb_table.html#attributes-reference) for locking of terraform state |
**Note about returning objects:** Because objects are returned (as opposed to just values), autocomplete may not work.
Just add on the key to the end out the output accessor. Even though autocomplete won't work, those values will still be
correctly returned.