Skip to content

Commit 47f291c

Browse files
committed
Adds generated docs
1 parent d59944b commit 47f291c

File tree

8 files changed

+315
-37
lines changed

8 files changed

+315
-37
lines changed

Jenkinsfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@Library( 'ops' ) _
2+
terraformModRepoBuilder()

Makefile

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
ifneq (,)
2+
.error This Makefile requires GNU Make.
3+
endif
4+
5+
.PHONY: help gen lint test _gen-main _gen-examples _gen-modules _lint_files _lint_fmt _pull-tf _pull-tf-docs
6+
7+
CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
8+
TF_EXAMPLES = $(sort $(dir $(wildcard $(CURRENT_DIR)examples/*/)))
9+
TF_MODULES = $(sort $(dir $(wildcard $(CURRENT_DIR)modules/*/)))
10+
11+
TF_VERSION = light
12+
TF_DOCS_VERSION = 0.9.1
13+
14+
# Adjust your delimiter here or overwrite via make arguments
15+
DELIM_START = <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
16+
DELIM_CLOSE = <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
17+
18+
help:
19+
@echo "gen Generate terraform-docs output and replace in all README.md's"
20+
@echo "lint Static source code analysis"
21+
@echo "test Integration tests"
22+
23+
gen: _pull-tf-docs
24+
@echo "################################################################################"
25+
@echo "# Terraform-docs generate"
26+
@echo "################################################################################"
27+
@$(MAKE) --no-print-directory _gen-main
28+
@$(MAKE) --no-print-directory _gen-examples
29+
@$(MAKE) --no-print-directory _gen-modules
30+
31+
lint: _pull-tf
32+
@$(MAKE) --no-print-directory _lint_files
33+
@$(MAKE) --no-print-directory _lint_fmt
34+
35+
test: _pull-tf
36+
@$(foreach example,\
37+
$(TF_EXAMPLES),\
38+
DOCKER_PATH="/t/examples/$(notdir $(patsubst %/,%,$(example)))"; \
39+
echo "################################################################################"; \
40+
echo "# examples/$$( basename $${DOCKER_PATH} )"; \
41+
echo "################################################################################"; \
42+
echo; \
43+
echo "------------------------------------------------------------"; \
44+
echo "# Terraform init"; \
45+
echo "------------------------------------------------------------"; \
46+
if docker run -it --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" hashicorp/terraform:$(TF_VERSION) \
47+
init \
48+
-verify-plugins=true \
49+
-lock=false \
50+
-upgrade=true \
51+
-reconfigure \
52+
-input=false \
53+
-get-plugins=true \
54+
-get=true \
55+
.; then \
56+
echo "OK"; \
57+
else \
58+
echo "Failed"; \
59+
docker run -it --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" --entrypoint=rm hashicorp/terraform:$(TF_VERSION) -rf .terraform/ || true; \
60+
exit 1; \
61+
fi; \
62+
echo; \
63+
echo "------------------------------------------------------------"; \
64+
echo "# Terraform validate"; \
65+
echo "------------------------------------------------------------"; \
66+
if docker run -it --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" hashicorp/terraform:$(TF_VERSION) \
67+
validate \
68+
$(ARGS) \
69+
.; then \
70+
echo "OK"; \
71+
docker run -it --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" --entrypoint=rm hashicorp/terraform:$(TF_VERSION) -rf .terraform/ || true; \
72+
else \
73+
echo "Failed"; \
74+
docker run -it --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" --entrypoint=rm hashicorp/terraform:$(TF_VERSION) -rf .terraform/ || true; \
75+
exit 1; \
76+
fi; \
77+
echo; \
78+
)
79+
80+
_gen-main:
81+
@echo "------------------------------------------------------------"
82+
@echo "# Main module"
83+
@echo "------------------------------------------------------------"
84+
@if docker run --rm \
85+
-v $(CURRENT_DIR):/data \
86+
-e DELIM_START='$(DELIM_START)' \
87+
-e DELIM_CLOSE='$(DELIM_CLOSE)' \
88+
cytopia/terraform-docs:$(TF_DOCS_VERSION) \
89+
terraform-docs-replace-012 --sort-inputs-by-required --with-aggregate-type-defaults md README.md; then \
90+
echo "OK"; \
91+
else \
92+
echo "Failed"; \
93+
exit 1; \
94+
fi
95+
96+
_gen-examples:
97+
@$(foreach example,\
98+
$(TF_EXAMPLES),\
99+
DOCKER_PATH="examples/$(notdir $(patsubst %/,%,$(example)))"; \
100+
echo "------------------------------------------------------------"; \
101+
echo "# $${DOCKER_PATH}"; \
102+
echo "------------------------------------------------------------"; \
103+
if docker run --rm \
104+
-v $(CURRENT_DIR):/data \
105+
--workdir "/data/$${DOCKER_PATH}" \
106+
-e DELIM_START='$(DELIM_START)' \
107+
-e DELIM_CLOSE='$(DELIM_CLOSE)' \
108+
cytopia/terraform-docs:$(TF_DOCS_VERSION) \
109+
terraform-docs-replace-012 --sort-inputs-by-required --with-aggregate-type-defaults md README.md; then \
110+
echo "OK"; \
111+
else \
112+
echo "Failed"; \
113+
exit 1; \
114+
fi; \
115+
)
116+
117+
_gen-modules:
118+
@$(foreach module,\
119+
$(TF_MODULES),\
120+
DOCKER_PATH="modules/$(notdir $(patsubst %/,%,$(module)))"; \
121+
echo "------------------------------------------------------------"; \
122+
echo "# $${DOCKER_PATH}"; \
123+
echo "------------------------------------------------------------"; \
124+
if docker run --rm \
125+
-v $(CURRENT_DIR):/data \
126+
-e DELIM_START='$(DELIM_START)' \
127+
-e DELIM_CLOSE='$(DELIM_CLOSE)' \
128+
cytopia/terraform-docs:$(TF_DOCS_VERSION) \
129+
terraform-docs-replace-012 --sort-inputs-by-required --with-aggregate-type-defaults md $${DOCKER_PATH}/README.md; then \
130+
echo "OK"; \
131+
else \
132+
echo "Failed"; \
133+
exit 1; \
134+
fi; \
135+
)
136+
137+
_lint_files:
138+
@# Lint all non-binary files for trailing spaces
139+
@echo "################################################################################"
140+
@echo "# Lint files"
141+
@echo "################################################################################"
142+
@echo
143+
@echo "------------------------------------------------------------"
144+
@echo "# Trailing spaces"
145+
@echo "------------------------------------------------------------"
146+
find . -type f -not \( -path "*/.git/*" -o -path "*/.github/*" -o -path "*/.terraform/*" -o -path "*/.idea/*"\) -print0 \
147+
| xargs -0 -n1 grep -Il '' \
148+
| tr '\n' '\0' \
149+
| xargs -0 -n1 \
150+
sh -c 'if [ -f "$${1}" ]; then if LC_ALL=C grep --color=always -inHE "^.*[[:blank:]]+$$" "$${1}";then false; else true; fi; fi' --
151+
@echo
152+
@echo "------------------------------------------------------------"
153+
@echo "# Windows line feeds (CRLF)"
154+
@echo "------------------------------------------------------------"
155+
find . -type f -not \( -path "*/.git/*" -o -path "*/.github/*" -o -path "*/.terraform/*" -o -path "*/.idea/*"\) -print0 \
156+
| xargs -0 -n1 grep -Il '' \
157+
| tr '\n' '\0' \
158+
| xargs -0 -n1 \
159+
sh -c 'if [ -f "$${1}" ]; then if file "$${1}" | grep --color=always -E "[[:space:]]CRLF[[:space:]].*line"; then false; else true; fi; fi' --
160+
@echo
161+
@echo "------------------------------------------------------------"
162+
@echo "# Single trailing newline"
163+
@echo "------------------------------------------------------------"
164+
find . -type f -not \( -path "*/.git/*" -o -path "*/.github/*" -o -path "*/.terraform/*" -o -path "*/.idea/*"\) -print0 \
165+
| xargs -0 -n1 grep -Il '' \
166+
| tr '\n' '\0' \
167+
| xargs -0 -n1 \
168+
sh -c 'if [ -f "$${1}" ]; then if ! (tail -c 1 "$${1}" | grep -Eq "^$$" && tail -c 2 "$${1}" | grep -Eqv "^$$"); then echo "$${1}"; false; else true; fi; fi' --
169+
@echo
170+
171+
_lint_fmt:
172+
@# Lint all Terraform files
173+
@echo "################################################################################"
174+
@echo "# Terraform fmt"
175+
@echo "################################################################################"
176+
@echo
177+
@echo "------------------------------------------------------------"
178+
@echo "# *.tf files"
179+
@echo "------------------------------------------------------------"
180+
@if docker run --rm -v "$(CURRENT_DIR):/t:ro" --workdir "/t" hashicorp/terraform:$(TF_VERSION) \
181+
fmt -check=true -diff=true -write=false -list=true /t; then \
182+
echo "OK"; \
183+
else \
184+
echo "Failed"; \
185+
exit 1; \
186+
fi;
187+
@echo "------------------------------------------------------------"
188+
@echo "# tfsec"
189+
@echo "------------------------------------------------------------"
190+
@if docker run --rm -v "$(CURRENT_DIR):/workdir:ro" --workdir "/workdir" tamr-docker.jfrog.io/ops/tfsec:v0.19.0 . ; then \
191+
echo "OK"; \
192+
else \
193+
echo "Failed"; \
194+
exit 1; \
195+
fi;
196+
@echo
197+
@echo "------------------------------------------------------------"
198+
@echo "# *.tfvars files"
199+
@echo "------------------------------------------------------------"
200+
@if docker run --rm --entrypoint=/bin/sh -v "$(CURRENT_DIR)/terraform:/t:ro" hashicorp/terraform:$(TF_VERSION) \
201+
-c "find . -name '*.tfvars' -type f -print0 | xargs -0 -n1 terraform fmt -check=true -write=false -diff=true -list=true"; then \
202+
echo "OK"; \
203+
else \
204+
echo "Failed"; \
205+
exit 1; \
206+
fi;
207+
@echo
208+
209+
_pull-tf:
210+
docker pull hashicorp/terraform:$(TF_VERSION)
211+
212+
_pull-tf-docs:
213+
docker pull cytopia/terraform-docs:$(TF_DOCS_VERSION)

README.md

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,35 +28,56 @@ This terraform module will create:
2828
* database parameter group
2929
* A security group for the rds instance
3030

31-
# Variables
31+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
32+
## Requirements
33+
34+
| Name | Version |
35+
|------|---------|
36+
| terraform | >= 0.12 |
37+
38+
## Providers
39+
40+
| Name | Version |
41+
|------|---------|
42+
| aws | n/a |
43+
3244
## Inputs
33-
* `password` (required): The postgres password
34-
* `tamr_vm_sg_id` (required): Security group id attached to the tamr vm
35-
* `spark_cluster_sg_id` (required): Security group is attached to the ec2 instances of EMR Spark
36-
* `vpc_id` (required): VPC ID for the rds security group
37-
* `username` (optional): The postgres username
38-
* `postgres_name` (optional): The name of the postgres instance
39-
* `parameter_group_name` (optional): The name of the rds parameter group
40-
* `identifier_prefix` (optional): Identifier prefix for the RDS instance
41-
* `subnet_name` (optional): The name of the subnet to add the RDS instance to
42-
* `allocated_storage` (optional): Allocate storage
43-
* `max_allocated_storage` (optional): Max allocate storage
44-
* `storage_type` (optional): Storage type (e.g. gp2, io1)
45-
* `instance_class` (optional): Instance class
46-
* `maintenance_window` (optional): Maintenance window
47-
* `backup_window` (optional): Backup window
48-
* `backup_retention_period` (optional): Backup retention period in days
49-
* `skip_final_snapshot` (optional): Skip final snapshot
50-
* `apply_immediately` (optional): Apply immediately, do not set this to true for production
51-
* `copy_tags_to_snapshot` (optional): Copy tags to snapshots
52-
* `additional_tags` (optional): Tags to set on the RDS instance
53-
* `security_group_name` (optional): Name for the security group for the rds instance
54-
* `additional_cidrs` (optional): Additional CIDR to connect to RDS Postgres instance
45+
46+
| Name | Description | Type | Default | Required |
47+
|------|-------------|------|---------|:--------:|
48+
| password | The postgres password | `string` | n/a | yes |
49+
| spark\_cluster\_sg\_ids | Security group is attached to the ec2 instances of EMR Spark | `list(string)` | n/a | yes |
50+
| tamr\_vm\_sg\_id | Security group id attached to the tamr vm | `string` | n/a | yes |
51+
| vpc\_id | VPC ID for the rds security group | `string` | n/a | yes |
52+
| additional\_cidrs | Additional CIDR to connect to RDS Postgres instance | `list(string)` | `[]` | no |
53+
| additional\_tags | Additional tags to set on the RDS instance | `map` | `{}` | no |
54+
| allocated\_storage | Allocate storage | `number` | `20` | no |
55+
| apply\_immediately | Apply immediately, do not set this to true for production | `bool` | `false` | no |
56+
| backup\_retention\_period | Backup retention period in days | `number` | `14` | no |
57+
| backup\_window | Backup window | `string` | `"03:29-03:59"` | no |
58+
| copy\_tags\_to\_snapshot | Copy tags to snapshots | `bool` | `true` | no |
59+
| identifier\_prefix | Identifier prefix for the RDS instance | `string` | `"tamr-rds-"` | no |
60+
| instance\_class | Instance class | `string` | `"db.m4.large"` | no |
61+
| maintenance\_window | Maintenance window | `string` | `"sun:04:32-sun:05:02"` | no |
62+
| max\_allocated\_storage | Max allocate storage | `number` | `1000` | no |
63+
| parameter\_group\_name | The name of the rds parameter group | `string` | `"rds-postgres-pg"` | no |
64+
| postgres\_name | The name of the postgres instance | `string` | `"tamr_rds_db"` | no |
65+
| security\_group\_name | Name for the security group for the rds instance | `string` | `"tamr_rds_sg"` | no |
66+
| skip\_final\_snapshot | Skip final snapshot | `bool` | `true` | no |
67+
| storage\_type | Storage type (e.g. gp2, io1) | `string` | `"gp2"` | no |
68+
| subnet\_name | The name of the subnet to add the RDS instance to | `string` | `null` | no |
69+
| username | The postgres username | `string` | `"tamr"` | no |
5570

5671
## Outputs
57-
* `rds_postgres_pg_id`: ID of the RDS postgres parameter group
58-
* `rds_postgres_id`: ID of the of the RDS instance
59-
* `rds_sg_id`: ID of the security group attached to the RDS instance
72+
73+
| Name | Description |
74+
|------|-------------|
75+
| rds\_hostname | n/a |
76+
| rds\_postgres\_id | ID of the of the RDS instance |
77+
| rds\_postgres\_pg\_id | ID of the RDS postgres parameter group |
78+
| rds\_sg\_id | ID of the security group attached to the rds instance |
79+
80+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
6081

6182
# References
6283
* AWS RDS: https://aws.amazon.com/rds/features/

examples/minimal/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2+
## Requirements
3+
4+
No requirements.
5+
6+
## Providers
7+
8+
No provider.
9+
10+
## Inputs
11+
12+
| Name | Description | Type | Default | Required |
13+
|------|-------------|------|---------|:--------:|
14+
| identifier\_prefix | Identifier prefix for the resources | `string` | n/a | yes |
15+
| parameter\_group\_name | Name of the parameter group | `string` | n/a | yes |
16+
| pg\_password | Password for postgres | `string` | n/a | yes |
17+
| pg\_username | Username for postgres | `string` | n/a | yes |
18+
| postgres\_db\_name | Name of the postgres db | `string` | n/a | yes |
19+
20+
## Outputs
21+
22+
No output.
23+
24+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
File renamed without changes.
File renamed without changes.
File renamed without changes.

modules/rds-postgres-sg/README.md

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,35 @@ module "rds_sg" {
1313
}
1414
```
1515

16-
# Variables
17-
## Inputs:
18-
* `tamr_vm_sg_id` (required): Security group id attached to the tamr vm
19-
* `spark_cluster_sg_ids` (required): List of Security groups attached to the ec2 instances of EMR Spark
20-
* `vpc_id` (required): VPC ID for the rds security group
21-
* `security_group_name` (optional): Name for the security group for the rds instance
22-
* `additional_cidrs` (optional): List of additional CIDR to connect to RDS Postgres instance
23-
* `additional_tags` (optional): Tags to set on the RDS instance security group
24-
25-
## Outputs:
26-
* `rds_sg_id`: ID of the security group attached to the RDS instance
16+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
17+
## Requirements
18+
19+
No requirements.
20+
21+
## Providers
22+
23+
| Name | Version |
24+
|------|---------|
25+
| aws | n/a |
26+
27+
## Inputs
28+
29+
| Name | Description | Type | Default | Required |
30+
|------|-------------|------|---------|:--------:|
31+
| spark\_cluster\_sg\_ids | List of Security groups attached to the ec2 instances of EMR Spark | `list(string)` | n/a | yes |
32+
| tamr\_vm\_sg\_id | Security group id attached to the tamr vm | `string` | n/a | yes |
33+
| vpc\_id | VPC ID for the rds security group | `string` | n/a | yes |
34+
| additional\_cidrs | Additional CIDR to connect to RDS Postgres instance | `list(string)` | `[]` | no |
35+
| additional\_tags | Additional tags to set on the RDS instance | `map` | `{}` | no |
36+
| security\_group\_name | Name for the security group for the rds instance | `string` | `"tamr_rds_sg"` | no |
37+
38+
## Outputs
39+
40+
| Name | Description |
41+
|------|-------------|
42+
| rds\_sg\_id | n/a |
43+
44+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2745

2846
# AWS Resources created
2947
This terraform module creates 1 Security Group:

0 commit comments

Comments
 (0)