Skip to content

Commit afacf7a

Browse files
authored
Clean up docs, remove hardcoded tags (#1)
1 parent 467fccf commit afacf7a

File tree

4 files changed

+50
-46
lines changed

4 files changed

+50
-46
lines changed

.pre-commit-config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
repos:
3+
- repo: git://github.com/antonbabenko/pre-commit-terraform
4+
rev: v1.19.0
5+
hooks:
6+
- id: terraform_fmt
7+
- id: terraform_docs
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v2.3.0
10+
hooks:
11+
- id: end-of-file-fixer
12+
- id: trailing-whitespace
13+
- id: no-commit-to-branch

README.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
# terraform-aws-backend
2-
Creates a backend S3 bucket and DynamoDB table for managing Terraform state
3-
4-
## Required Variables
5-
* `region`
6-
* `namespace`
7-
* `owner`
8-
* `bucket`
9-
* `table`
10-
11-
## Optional Variables
12-
* `extra_tags` = `{}`
13-
* `env` = `global`
2+
3+
[![](https://github.com/rhythmictech/terraform-aws-backend/workflows/check/badge.svg)](https://github.com/rhythmictech/terraform-aws-backend/actions)
4+
5+
Creates a backend S3 bucket and DynamoDB table for managing Terraform state. Useful for bootstrapping a new
6+
environment.
7+
8+
## Usage
9+
```
10+
module "backend" {
11+
source = "git::ssh://git@github.com/rhythmictech/terraform-aws-backend"
12+
bucket = "project-tfstate"
13+
region = "us-east-1"
14+
table = "tf-locktable"
15+
}
16+
17+
```
18+
19+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
20+
## Inputs
21+
22+
| Name | Description | Type | Default | Required |
23+
|------|-------------|:----:|:-----:|:-----:|
24+
| bucket | Name of bucket to create | string | n/a | yes |
25+
| region | | string | n/a | yes |
26+
| table | Name of Dynamo Table to create | string | n/a | yes |
27+
| tags | Mapping of any extra tags you want added to resources | map(string) | `{}` | no |
28+
29+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

main.tf

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ resource "aws_s3_bucket" "config_bucket" {
33
acl = "log-delivery-write"
44

55
tags = merge(
6-
local.common_tags,
7-
var.extra_tags,
6+
var.tags,
87
{
98
"Name" = "tf-state"
109
},
@@ -56,11 +55,9 @@ resource "aws_dynamodb_table" "terraform_statelock" {
5655
}
5756

5857
tags = merge(
59-
local.common_tags,
60-
var.extra_tags,
58+
var.tags,
6159
{
6260
"Name" = "tf-locktable"
6361
},
6462
)
6563
}
66-

variables.tf

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,23 @@
11
data "aws_caller_identity" "current" {
22
}
33

4-
locals {
5-
common_tags = {
6-
namespace = var.namespace
7-
owner = var.owner
8-
env = var.env
9-
}
4+
variable "bucket" {
5+
description = "Name of bucket to create"
6+
type = string
107
}
118

129
variable "region" {
1310
type = string
1411
}
1512

16-
variable "namespace" {
17-
type = string
18-
}
19-
20-
variable "owner" {
21-
type = string
22-
}
23-
24-
variable "env" {
25-
type = string
26-
default = "global"
13+
variable "table" {
14+
description = "Name of Dynamo Table to create"
15+
type = string
2716
}
2817

29-
variable "extra_tags" {
18+
variable "tags" {
3019
description = "Mapping of any extra tags you want added to resources"
3120
type = map(string)
3221
default = {
3322
}
3423
}
35-
36-
variable "bucket" {
37-
description = "Name of bucket to create"
38-
type = string
39-
}
40-
41-
variable "table" {
42-
description = "Name of Dynamo Table to create"
43-
type = string
44-
}
45-

0 commit comments

Comments
 (0)