Skip to content

Commit 71fa06c

Browse files
authored
feat: adding support for multiple regions (#25)
* feat: adding support for multiple regions * chore: bringing in the upstream changes * chore: removing to the lockfile * docs: updating the documentation
1 parent 8ac8b7c commit 71fa06c

14 files changed

+283
-115
lines changed

.commitlintrc.yaml

+19
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

+15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*.tfstate
66
*.tfstate.*
77

8+
# Terraform lock file
9+
.terraform.lock.hcl
10+
811
# Crash log files
912
crash.log
1013
crash.*.log
@@ -30,3 +33,15 @@ terraform.rc
3033
.DS_Store
3134
todo.md
3235

36+
# Ignore vim swap files
37+
*.swp
38+
*.swo
39+
40+
# Ignore meld diff files
41+
*.orig
42+
*.backup
43+
*.rej
44+
45+
# Ignore lambda zip files and build directories
46+
*.zip
47+
builds/

.terraform-docs.yaml .terraform-docs.yml

+11-4
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

.terraform.lock.hcl

+16-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.tflint.hcl

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +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

77
plugin "terraform" {
8-
enabled = true
9-
version = "0.7.0"
10-
source = "github.com/terraform-linters/tflint-ruleset-terraform"
8+
enabled = true
9+
version = "0.9.1"
10+
source = "github.com/terraform-linters/tflint-ruleset-terraform"
1111
}
1212

1313
config {
1414
call_module_type = "local"
15-
force = false
15+
force = false
1616
}
1717

1818
rule "terraform_required_providers" {

.trivyignore

Whitespace-only changes.

Makefile

+70-49
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@
1212
# You should have received a copy of the GNU General Public License
1313
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1414
#
15-
.PHONY: all security lint format documentation documentation-examples validate-all validate validate-examples init examples
15+
.PHONY: all security lint format documentation documentation-examples validate-all validate validate-examples init examples tests
1616

1717
default: all
1818

1919
all:
2020
$(MAKE) init
2121
$(MAKE) validate
22+
$(MAKE) tests
2223
$(MAKE) lint
2324
$(MAKE) security
2425
$(MAKE) format
2526
$(MAKE) documentation
2627

2728
examples:
2829
$(MAKE) validate-examples
30+
$(MAKE) tests
2931
$(MAKE) lint-examples
3032
$(MAKE) lint
3133
$(MAKE) security
@@ -34,76 +36,99 @@ examples:
3436

3537
documentation:
3638
@echo "--> Generating documentation"
37-
@terraform-docs markdown table --output-file ${PWD}/README.md --output-mode inject .
39+
@terraform-docs .
3840
$(MAKE) documentation-modules
3941
$(MAKE) documentation-examples
4042

4143
documentation-modules:
4244
@echo "--> Generating documentation for modules"
43-
@if [ -d modules ]; then \
44-
find modules -type d -mindepth 1 -maxdepth 1 -exec terraform-docs markdown table --output-file README.md --output-mode inject {} \; ; \
45-
fi
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;
4649

4750
documentation-examples:
48-
@echo "--> Generating documentation examples"
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:
4963
@if [ -d examples ]; then \
50-
find examples -type d -mindepth 1 -maxdepth 1 -exec terraform-docs markdown table --output-file README.md --output-mode inject {} \; ; \
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; \
5168
fi
5269

5370
init:
5471
@echo "--> Running terraform init"
5572
@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;
5677

57-
security:
78+
security: init
5879
@echo "--> Running Security checks"
5980
@trivy config .
6081
$(MAKE) security-modules
6182
$(MAKE) security-examples
6283

6384
security-modules:
6485
@echo "--> Running Security checks on modules"
65-
@if [ -d modules ]; then \
66-
find modules -type d -mindepth 1 -maxdepth 1 | while read -r dir; do \
67-
echo "--> Validating $$dir"; \
68-
trivy config $$dir; \
69-
done; \
70-
fi
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;
7191

7292
security-examples:
7393
@echo "--> Running Security checks on examples"
74-
@if [ -d examples ]; then \
75-
find examples -type d -mindepth 1 -maxdepth 1 | while read -r dir; do \
76-
echo "--> Validating $$dir"; \
77-
trivy config $$dir; \
78-
done; \
79-
fi
94+
@find . -type d -path '*/examples/*' -not -path '*.terraform*' 2>/dev/null | while read -r dir; do \
95+
echo "--> Validating $$dir"; \
96+
terraform init -backend=false; \
97+
trivy config --format table --exit-code 1 --severity CRITICAL,HIGH --ignorefile .trivyignore $$dir; \
98+
done;
99+
100+
tests:
101+
@echo "--> Running Terraform Tests"
102+
@terraform test
80103

81104
validate:
82105
@echo "--> Running terraform validate"
83106
@terraform init -backend=false
84107
@terraform validate
85108
$(MAKE) validate-modules
86109
$(MAKE) validate-examples
110+
$(MAKE) validate-commits
87111

88112
validate-modules:
89113
@echo "--> Running terraform validate on modules"
90-
@if [ -d modules ]; then \
91-
find modules -type d -mindepth 1 -maxdepth 1 | while read -r dir; do \
92-
echo "--> Validating $$dir"; \
93-
terraform -chdir=$$dir init -backend=false; \
94-
terraform -chdir=$$dir validate; \
95-
done; \
96-
fi
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;
97119

98120
validate-examples:
99121
@echo "--> Running terraform validate on examples"
100-
@if [ -d examples ]; then \
101-
find examples -type d -mindepth 1 -maxdepth 1 | while read -r dir; do \
102-
echo "--> Validating $$dir"; \
103-
terraform -chdir=$$dir init -backend=false; \
104-
terraform -chdir=$$dir validate; \
105-
done; \
106-
fi
122+
@find . -type d -path '*/examples/*' -not -path '*.terraform*' 2>/dev/null | while read -r dir; do \
123+
echo "--> Validating $$dir"; \
124+
terraform -chdir=$$dir init -backend=false; \
125+
terraform -chdir=$$dir validate; \
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
107132

108133
lint:
109134
@echo "--> Running tflint"
@@ -114,31 +139,27 @@ lint:
114139

115140
lint-modules:
116141
@echo "--> Running tflint on modules"
117-
@if [ -d modules ]; then \
118-
find modules -type d -mindepth 1 -maxdepth 1 | while read -r dir; do \
119-
echo "--> Linting $$dir"; \
120-
tflint --chdir=$$dir --init; \
121-
tflint --chdir=$$dir -f compact; \
122-
done; \
123-
fi
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;
124147

125148
lint-examples:
126149
@echo "--> Running tflint on examples"
127-
@if [ -d examples ]; then \
128-
find examples -type d -mindepth 1 -maxdepth 1 | while read -r dir; do \
129-
echo "--> Linting $$dir"; \
130-
tflint --chdir=$$dir --init; \
131-
tflint --chdir=$$dir -f compact; \
132-
done; \
133-
fi
150+
@find . -type d -path '*/examples/*' -not -path '*.terraform*' 2>/dev/null | while read -r dir; do \
151+
echo "--> Linting $$dir"; \
152+
tflint --chdir=$$dir --init; \
153+
tflint --chdir=$$dir -f compact; \
154+
done;
134155

135156
format:
136157
@echo "--> Running terraform fmt"
137158
@terraform fmt -recursive -write=true
138159

139160
clean:
140161
@echo "--> Cleaning up"
141-
@find . -type d -name ".terraform" | while read -r dir; do \
162+
@find . -type d -name ".terraform" 2>/dev/null | while read -r dir; do \
142163
echo "--> Removing $$dir"; \
143164
rm -rf $$dir; \
144165
done

README.md

+1-19
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
11

22
<!-- BEGIN_TF_DOCS -->
3-
## Requirements
4-
5-
| Name | Version |
6-
|------|---------|
7-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.7 |
8-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0.0 |
9-
103
## Providers
114

125
| Name | Version |
136
|------|---------|
147
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0.0 |
158

16-
## Modules
17-
18-
No modules.
19-
20-
## Resources
21-
22-
| Name | Type |
23-
|------|------|
24-
| [aws_cloudformation_stack_set.stackset](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack_set) | resource |
25-
| [aws_cloudformation_stack_set_instance.ou](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack_set_instance) | resource |
26-
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
27-
289
## Inputs
2910

3011
| Name | Description | Type | Default | Required |
@@ -34,6 +15,7 @@ No modules.
3415
| <a name="input_tags"></a> [tags](#input\_tags) | The tags to apply to the cloudformation stack | `map(string)` | n/a | yes |
3516
| <a name="input_template"></a> [template](#input\_template) | The body of the cloudformation template to deploy | `string` | n/a | yes |
3617
| <a name="input_capabilities"></a> [capabilities](#input\_capabilities) | The capabilities required to deploy the cloudformation template | `list(string)` | <pre>[<br/> "CAPABILITY_NAMED_IAM",<br/> "CAPABILITY_AUTO_EXPAND",<br/> "CAPABILITY_IAM"<br/>]</pre> | no |
18+
| <a name="input_enabled_regions"></a> [enabled\_regions](#input\_enabled\_regions) | The regions to deploy the cloudformation stack to (if empty, deploys to current region) | `list(string)` | `null` | no |
3719
| <a name="input_failure_tolerance_count"></a> [failure\_tolerance\_count](#input\_failure\_tolerance\_count) | The number of failures that are tolerated before the stack operation is stopped | `number` | `0` | no |
3820
| <a name="input_max_concurrent_count"></a> [max\_concurrent\_count](#input\_max\_concurrent\_count) | The maximum number of concurrent deployments | `number` | `10` | no |
3921
| <a name="input_organizational_units"></a> [organizational\_units](#input\_organizational\_units) | The organizational units to deploy the stackset to | `list(string)` | `[]` | no |

0 commit comments

Comments
 (0)