Skip to content

Commit fead0c8

Browse files
committed
chore: bring the repository inline with the templates
1 parent 6812b81 commit fead0c8

File tree

15 files changed

+218
-134
lines changed

15 files changed

+218
-134
lines changed

.commitlintrc.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
rules:
3+
body-leading-blank: [1, always]
4+
body-max-line-length: [2, always, 100]
5+
footer-leading-blank: [1, always]
6+
footer-max-line-length: [2, always, 100]
7+
header-max-length: [2, always, 100]
8+
subject-case:
9+
- 2
10+
- never
11+
- [sentence-case, start-case, pascal-case, upper-case]
12+
subject-empty: [2, never]
13+
subject-full-stop: [2, never, "."]
14+
type-case: [2, always, lower-case]
15+
type-empty: [2, never]
16+
type-enum:
17+
- 2
18+
- always
19+
- [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test]

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,15 @@ terraform.rc
3030
.DS_Store
3131
todo.md
3232

33+
# Ignore vim swap files
34+
*.swp
35+
*.swo
36+
37+
# Ignore meld diff files
38+
*.orig
39+
*.backup
40+
*.rej
41+
42+
# Ignore lambda zip files and build directories
43+
*.zip
44+
builds/
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
formatter: markdown
21
#header-from: .header.md
32
settings:
43
anchor: true
@@ -12,10 +11,18 @@ settings:
1211
type: true
1312
lockfile: false
1413

15-
sort:
16-
enabled: true
17-
by: required
14+
formatter: "markdown table"
1815

1916
output:
2017
file: README.md
2118
mode: inject
19+
20+
sections:
21+
show:
22+
- providers
23+
- inputs
24+
- outputs
25+
26+
sort:
27+
enabled: true
28+
by: required

.tflint.hcl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
plugin "aws" {
22
enabled = true
3-
version = "0.30.0"
3+
version = "0.34.0"
44
source = "github.com/terraform-linters/tflint-ruleset-aws"
55
}
66

7+
plugin "terraform" {
8+
enabled = true
9+
version = "0.9.1"
10+
source = "github.com/terraform-linters/tflint-ruleset-terraform"
11+
}
12+
713
config {
8-
module = true
9-
force = false
14+
call_module_type = "local"
15+
force = false
1016
}
1117

1218
rule "terraform_required_providers" {

Makefile

Lines changed: 89 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#
2-
# Copyright (C) 2024 Appvia Ltd <[email protected]>
3-
#
42
# This program is free software; you can redistribute it and/or
53
# modify it under the terms of the GNU General Public License
64
# as published by the Free Software Foundation; either version 2
@@ -14,92 +12,154 @@
1412
# You should have received a copy of the GNU General Public License
1513
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1614
#
17-
AUTHOR_EMAIL[email protected]
18-
19-
.PHONY: all security lint format documentation documentation-examples validate-all validate validate-examples init
15+
.PHONY: all security lint format documentation documentation-examples validate-all validate validate-examples init examples tests
2016

2117
default: all
2218

2319
all:
2420
$(MAKE) init
2521
$(MAKE) validate
22+
$(MAKE) tests
23+
$(MAKE) lint
24+
$(MAKE) security
25+
$(MAKE) format
26+
$(MAKE) documentation
27+
28+
examples:
29+
$(MAKE) validate-examples
30+
$(MAKE) tests
31+
$(MAKE) lint-examples
2632
$(MAKE) lint
2733
$(MAKE) security
2834
$(MAKE) format
2935
$(MAKE) documentation
3036

3137
documentation:
3238
@echo "--> Generating documentation"
33-
@terraform-docs markdown table --output-file ${PWD}/README.md --output-mode inject .
39+
@terraform-docs .
40+
$(MAKE) documentation-modules
3441
$(MAKE) documentation-examples
3542

43+
documentation-modules:
44+
@echo "--> Generating documentation for modules"
45+
@find . -type d -regex '.*/modules/[a-za-z\-_$$]*' -not -path '*.terraform*' 2>/dev/null | while read -r dir; do \
46+
echo "--> Generating documentation for module: $$dir"; \
47+
terraform-docs $$dir; \
48+
done;
49+
3650
documentation-examples:
37-
@echo "--> Generating documentation examples"
38-
@find examples -type d -mindepth 1 -maxdepth 1 -exec terraform-docs markdown table --output-file README.md --output-mode inject {} \;
51+
@echo "--> Generating documentation for examples"
52+
@find . -type d -path '*/examples/*' -not -path '*.terraform*' 2>/dev/null| while read -r dir; do \
53+
echo "--> Generating documentation for example: $$dir"; \
54+
terraform-docs $$dir; \
55+
done;
56+
57+
upgrade-terraform-providers:
58+
@printf "%s Upgrading Terraform providers for %-24s" "-->" "."
59+
@terraform init -upgrade >/dev/null && echo "[OK]" || echo "[FAILED]"
60+
@$(MAKE) upgrade-terraform-example-providers
61+
62+
upgrade-terraform-example-providers:
63+
@if [ -d examples ]; then \
64+
find examples -type d -mindepth 1 -maxdepth 1 2>/dev/null | while read -r dir; do \
65+
printf "%s Upgrading Terraform providers for %-24s" "-->" "$$dir"; \
66+
terraform -chdir=$$dir init -upgrade >/dev/null && echo "[OK]" || echo "[FAILED]"; \
67+
done; \
68+
fi
3969

4070
init:
4171
@echo "--> Running terraform init"
4272
@terraform init -backend=false
73+
@find . -type f -name "*.tf" -not -path '*.terraform*' -exec dirname {} \; | sort -u | while read -r dir; do \
74+
echo "--> Running terraform init in $$dir"; \
75+
terraform -chdir=$$dir init -backend=false; \
76+
done;
4377

44-
security:
78+
security: init
4579
@echo "--> Running Security checks"
4680
@trivy config .
81+
$(MAKE) security-modules
4782
$(MAKE) security-examples
4883

84+
security-modules:
85+
@echo "--> Running Security checks on modules"
86+
@find . -type d -regex '.*/modules/[a-zA-Z\-_$$]*' -not -path '*.terraform*' 2>/dev/null | while read -r dir; do \
87+
echo "--> Validating $$dir"; \
88+
terraform init -backend=false; \
89+
trivy config --format table --exit-code 1 --severity CRITICAL,HIGH --ignorefile .trivyignore $$dir; \
90+
done;
91+
4992
security-examples:
5093
@echo "--> Running Security checks on examples"
51-
@find examples -type d -mindepth 1 -maxdepth 1 | while read -r dir; do \
94+
@find . -type d -path '*/examples/*' -not -path '*.terraform*' 2>/dev/null | while read -r dir; do \
5295
echo "--> Validating $$dir"; \
53-
trivy config $$dir; \
54-
done
96+
terraform init -backend=false; \
97+
trivy config --format table --exit-code 1 --severity CRITICAL,HIGH --ignorefile .trivyignore $$dir; \
98+
done;
5599

56-
validate-all:
57-
@echo "--> Running all validation checks"
58-
$(MAKE) validate
59-
$(MAKE) validate-examples
100+
tests:
101+
@echo "--> Running Terraform Tests"
102+
@terraform test
60103

61104
validate:
62105
@echo "--> Running terraform validate"
63106
@terraform init -backend=false
64107
@terraform validate
108+
$(MAKE) validate-modules
65109
$(MAKE) validate-examples
110+
$(MAKE) validate-commits
111+
112+
validate-modules:
113+
@echo "--> Running terraform validate on modules"
114+
@find . -type d -regex '.*/modules/[a-zA-Z\-_$$]*' -not -path '*.terraform*' 2>/dev/null | while read -r dir; do \
115+
echo "--> Validating Module $$dir"; \
116+
terraform -chdir=$$dir init -backend=false; \
117+
terraform -chdir=$$dir validate; \
118+
done;
66119

67120
validate-examples:
68121
@echo "--> Running terraform validate on examples"
69-
@find examples -type d -mindepth 1 -maxdepth 1 | while read -r dir; do \
122+
@find . -type d -path '*/examples/*' -not -path '*.terraform*' 2>/dev/null | while read -r dir; do \
70123
echo "--> Validating $$dir"; \
71-
terraform -chdir=$$dir init; \
124+
terraform -chdir=$$dir init -backend=false; \
72125
terraform -chdir=$$dir validate; \
73-
done
126+
done;
127+
128+
validate-commits:
129+
@echo "--> Running commitlint against the main branch"
130+
@command -v commitlint >/dev/null 2>&1 || { echo "commitlint is not installed. Please install it by running 'npm install -g commitlint'"; exit 1; }
131+
@git log --pretty=format:"%s" origin/main..HEAD | commitlint --from=origin/main
74132

75133
lint:
76134
@echo "--> Running tflint"
77135
@tflint --init
78136
@tflint -f compact
137+
$(MAKE) lint-modules
79138
$(MAKE) lint-examples
80139

140+
lint-modules:
141+
@echo "--> Running tflint on modules"
142+
@find . -type d -regex '.*/modules/[a-zA-Z\-_$$]*' -not -path '*.terraform*' 2>/dev/null | while read -r dir; do \
143+
echo "--> Linting $$dir"; \
144+
tflint --chdir=$$dir --init; \
145+
tflint --chdir=$$dir -f compact; \
146+
done;
147+
81148
lint-examples:
82149
@echo "--> Running tflint on examples"
83-
@find examples -type d -mindepth 1 -maxdepth 1 | while read -r dir; do \
150+
@find . -type d -path '*/examples/*' -not -path '*.terraform*' 2>/dev/null | while read -r dir; do \
84151
echo "--> Linting $$dir"; \
85152
tflint --chdir=$$dir --init; \
86153
tflint --chdir=$$dir -f compact; \
87-
done
154+
done;
88155

89156
format:
90157
@echo "--> Running terraform fmt"
91158
@terraform fmt -recursive -write=true
92159

93160
clean:
94161
@echo "--> Cleaning up"
95-
@find . -type d -name ".terraform" | while read -r dir; do \
162+
@find . -type d -name ".terraform" 2>/dev/null | while read -r dir; do \
96163
echo "--> Removing $$dir"; \
97164
rm -rf $$dir; \
98165
done
99-
100-
verify-rules:
101-
@echo "Validating the Suricata rules"
102-
$(MAKE) verify-duplicates
103-
104-
verify-duplicates:
105-
@echo "Validating the Suricata rules for duplicates"

README.md

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -258,54 +258,12 @@ module "network_inspection_vpc_admin" {
258258
```
259259

260260
<!-- BEGIN_TF_DOCS -->
261-
## Requirements
262-
263-
| Name | Version |
264-
|------|---------|
265-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
266-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.0 |
267-
268261
## Providers
269262

270263
| Name | Version |
271264
|------|---------|
272265
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.0 |
273266

274-
## Modules
275-
276-
| Name | Source | Version |
277-
|------|--------|---------|
278-
| <a name="module_network_firewall"></a> [network\_firewall](#module\_network\_firewall) | aws-ia/networkfirewall/aws | 1.0.1 |
279-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | appvia/network/aws | 0.3.1 |
280-
281-
## Resources
282-
283-
| Name | Type |
284-
|------|------|
285-
| [aws_cloudformation_stack.dashboard](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack) | resource |
286-
| [aws_cloudwatch_log_group.alert_log](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource |
287-
| [aws_cloudwatch_log_group.flow_log](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource |
288-
| [aws_ec2_managed_prefix_list.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_managed_prefix_list) | resource |
289-
| [aws_kms_key.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource |
290-
| [aws_networkfirewall_firewall_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/networkfirewall_firewall_policy) | resource |
291-
| [aws_networkfirewall_rule_group.stateful](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/networkfirewall_rule_group) | resource |
292-
| [aws_ram_principal_association.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ram_principal_association) | resource |
293-
| [aws_ram_resource_association.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ram_resource_association) | resource |
294-
| [aws_ram_resource_share.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ram_resource_share) | resource |
295-
| [aws_s3_bucket.dashboard](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
296-
| [aws_s3_bucket_acl.dashboard](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource |
297-
| [aws_s3_bucket_ownership_controls.dashboard](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |
298-
| [aws_s3_bucket_policy.dashboard](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
299-
| [aws_s3_bucket_public_access_block.dashboard](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |
300-
| [aws_s3_bucket_server_side_encryption_configuration.dashboard](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource |
301-
| [aws_s3_bucket_versioning.dashboard](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_versioning) | resource |
302-
| [aws_s3_object.dashboard](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_object) | resource |
303-
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
304-
| [aws_iam_policy_document.dashboard](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
305-
| [aws_iam_policy_document.logging](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
306-
| [aws_kms_key.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/kms_key) | data source |
307-
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
308-
309267
## Inputs
310268

311269
| Name | Description | Type | Default | Required |

examples/existing_no_egress/README.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
11
<!-- BEGIN_TF_DOCS -->
2-
## Requirements
3-
4-
| Name | Version |
5-
|------|---------|
6-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
7-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0.0 |
8-
| <a name="requirement_awscc"></a> [awscc](#requirement\_awscc) | >= 0.11.0 |
9-
102
## Providers
113

124
No providers.
135

14-
## Modules
15-
16-
| Name | Source | Version |
17-
|------|--------|---------|
18-
| <a name="module_inspection"></a> [inspection](#module\_inspection) | ../.. | n/a |
19-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | appvia/network/aws | 0.2.1 |
20-
21-
## Resources
22-
23-
No resources.
24-
256
## Inputs
267

278
| Name | Description | Type | Default | Required |
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- BEGIN_TF_DOCS -->
2+
## Providers
3+
4+
No providers.
5+
6+
## Inputs
7+
8+
No inputs.
9+
10+
## Outputs
11+
12+
No outputs.
13+
<!-- END_TF_DOCS -->
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- BEGIN_TF_DOCS -->
2+
## Providers
3+
4+
No providers.
5+
6+
## Inputs
7+
8+
No inputs.
9+
10+
## Outputs
11+
12+
No outputs.
13+
<!-- END_TF_DOCS -->

0 commit comments

Comments
 (0)