Skip to content

Commit c29d803

Browse files
authored
feat: update minimum required versions of AWS provider to >= 3.0 and Terraform >= 0.13.1, update pre-commit and CI configs to latest (#230)
1 parent d935bae commit c29d803

File tree

182 files changed

+579
-455
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+579
-455
lines changed

.github/workflows/pre-commit.yml

Lines changed: 45 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2,101 +2,81 @@ name: Pre-Commit
22

33
on:
44
pull_request:
5-
push:
65
branches:
6+
- main
77
- master
88

9+
env:
10+
TERRAFORM_DOCS_VERSION: v0.16.0
11+
912
jobs:
10-
# Min Terraform version(s)
11-
getDirectories:
12-
name: Get root directories
13+
collectInputs:
14+
name: Collect workflow inputs
1315
runs-on: ubuntu-latest
16+
outputs:
17+
directories: ${{ steps.dirs.outputs.directories }}
1418
steps:
1519
- name: Checkout
1620
uses: actions/checkout@v2
17-
- name: Install Python
18-
uses: actions/setup-python@v2
19-
- name: Build matrix
20-
id: matrix
21-
run: |
22-
DIRS=$(python -c "import json; import glob; import re; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True) if not re.match(r'^.+/_', x)]))")
23-
echo "::set-output name=directories::$DIRS"
24-
outputs:
25-
directories: ${{ steps.matrix.outputs.directories }}
21+
22+
- name: Get root directories
23+
id: dirs
24+
uses: clowdhaus/terraform-composite-actions/directories@v1.3.0
2625

2726
preCommitMinVersions:
28-
name: Min TF validate
29-
needs: getDirectories
27+
name: Min TF pre-commit
28+
needs: collectInputs
3029
runs-on: ubuntu-latest
3130
strategy:
3231
matrix:
33-
directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}
32+
directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}
3433
steps:
3534
- name: Checkout
3635
uses: actions/checkout@v2
37-
- name: Install Python
38-
uses: actions/setup-python@v2
36+
3937
- name: Terraform min/max versions
4038
id: minMax
41-
uses: clowdhaus/terraform-min-max@v1.0.2
39+
uses: clowdhaus/terraform-min-max@v1.0.3
4240
with:
4341
directory: ${{ matrix.directory }}
44-
- name: Install Terraform v${{ steps.minMax.outputs.minVersion }}
45-
uses: hashicorp/setup-terraform@v1
46-
with:
47-
terraform_version: ${{ steps.minMax.outputs.minVersion }}
48-
- name: Install pre-commit dependencies
49-
run: pip install pre-commit
50-
- name: Execute pre-commit
42+
43+
- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
5144
# Run only validate pre-commit check on min version supported
5245
if: ${{ matrix.directory != '.' }}
53-
run: pre-commit run terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*
54-
- name: Execute pre-commit
46+
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.3.0
47+
with:
48+
terraform-version: ${{ steps.minMax.outputs.minVersion }}
49+
args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'
50+
51+
- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
5552
# Run only validate pre-commit check on min version supported
5653
if: ${{ matrix.directory == '.' }}
57-
run: pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)
54+
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.3.0
55+
with:
56+
terraform-version: ${{ steps.minMax.outputs.minVersion }}
57+
args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'
5858

59-
# Max Terraform version
60-
getBaseVersion:
61-
name: Module max TF version
59+
preCommitMaxVersion:
60+
name: Max TF pre-commit
6261
runs-on: ubuntu-latest
62+
needs: collectInputs
6363
steps:
6464
- name: Checkout
6565
uses: actions/checkout@v2
66+
with:
67+
ref: ${{ github.event.pull_request.head.ref }}
68+
repository: ${{github.event.pull_request.head.repo.full_name}}
69+
6670
- name: Terraform min/max versions
6771
id: minMax
68-
uses: clowdhaus/terraform-min-max@v1.0.2
69-
outputs:
70-
minVersion: ${{ steps.minMax.outputs.minVersion }}
71-
maxVersion: ${{ steps.minMax.outputs.maxVersion }}
72+
uses: clowdhaus/terraform-min-max@v1.0.3
7273

73-
preCommitMaxVersion:
74-
name: Max TF pre-commit
75-
runs-on: ubuntu-latest
76-
needs: getBaseVersion
77-
strategy:
78-
fail-fast: false
79-
matrix:
80-
version:
81-
- ${{ needs.getBaseVersion.outputs.maxVersion }}
82-
steps:
83-
- name: Checkout
84-
uses: actions/checkout@v2
85-
- name: Install Python
86-
uses: actions/setup-python@v2
87-
- name: Install Terraform v${{ matrix.version }}
88-
uses: hashicorp/setup-terraform@v1
74+
# Special to this repo, we don't want to check this dir
75+
- name: Hide template dir
76+
run: rm -rf modules/_templates
77+
78+
- name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}
79+
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.3.0
8980
with:
90-
terraform_version: ${{ matrix.version }}
91-
- name: Install pre-commit dependencies
92-
run: |
93-
pip install pre-commit
94-
curl -Lo ./terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/v0.13.0/terraform-docs-v0.13.0-$(uname)-amd64.tar.gz && tar -xzf terraform-docs.tar.gz && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/
95-
- name: Execute pre-commit (terraform_fmt)
96-
# Run all pre-commit checks on max version supported
97-
if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}
98-
run: pre-commit run terraform_fmt --color=always --show-diff-on-failure --all-files
99-
- name: Execute pre-commit (terraform_docs)
100-
# Run all pre-commit checks on max version supported
101-
if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}
102-
run: pre-commit run terraform_docs --color=always --show-diff-on-failure --all-files
81+
terraform-version: ${{ steps.minMax.outputs.maxVersion }}
82+
terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}

.pre-commit-config.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
repos:
2-
- repo: git://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.50.0
2+
- repo: https://github.com/antonbabenko/pre-commit-terraform
3+
rev: v1.56.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_validate
77
- id: terraform_docs
8-
- repo: git://github.com/pre-commit/pre-commit-hooks
8+
args:
9+
- '--args=--lockfile=false'
10+
- repo: https://github.com/pre-commit/pre-commit-hooks
911
rev: v4.0.1
1012
hooks:
1113
- id: check-merge-conflict
14+
- id: end-of-file-fixer

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ No issue is creating limit on this module.
157157

158158
| Name | Version |
159159
|------|---------|
160-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.6 |
161-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.42 |
160+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
161+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.0 |
162162

163163
## Providers
164164

165165
| Name | Version |
166166
|------|---------|
167-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 2.42 |
167+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.0 |
168168

169169
## Modules
170170

@@ -214,8 +214,8 @@ No modules.
214214
| <a name="input_computed_ingress_with_source_security_group_id"></a> [computed\_ingress\_with\_source\_security\_group\_id](#input\_computed\_ingress\_with\_source\_security\_group\_id) | List of computed ingress rules to create where 'source\_security\_group\_id' is used | `list(map(string))` | `[]` | no |
215215
| <a name="input_create"></a> [create](#input\_create) | Whether to create security group and all rules | `bool` | `true` | no |
216216
| <a name="input_create_sg"></a> [create\_sg](#input\_create\_sg) | Whether to create security group | `bool` | `true` | no |
217-
| <a name="input_create_timeout"></a> [create_timeout](#input\_create\_timeout) | Time to wait for a security group to be created | `string` | `10m` | no |
218-
| <a name="input_delete_timeout"></a> [delete_timeout](#input\_delete\_timeout) | Time to wait for a security group to be deleted | `string` | `15m` | no |
217+
| <a name="input_create_timeout"></a> [create\_timeout](#input\_create\_timeout) | Time to wait for a security group to be created | `string` | `"10m"` | no |
218+
| <a name="input_delete_timeout"></a> [delete\_timeout](#input\_delete\_timeout) | Time to wait for a security group to be deleted | `string` | `"15m"` | no |
219219
| <a name="input_description"></a> [description](#input\_description) | Description of security group | `string` | `"Security Group managed by Terraform"` | no |
220220
| <a name="input_egress_cidr_blocks"></a> [egress\_cidr\_blocks](#input\_egress\_cidr\_blocks) | List of IPv4 CIDR ranges to use on all egress rules | `list(string)` | <pre>[<br> "0.0.0.0/0"<br>]</pre> | no |
221221
| <a name="input_egress_ipv6_cidr_blocks"></a> [egress\_ipv6\_cidr\_blocks](#input\_egress\_ipv6\_cidr\_blocks) | List of IPv6 CIDR ranges to use on all egress rules | `list(string)` | <pre>[<br> "::/0"<br>]</pre> | no |

examples/complete/README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,27 @@ Note that this example may create resources which cost money. Run `terraform des
1919
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2020
## Requirements
2121

22-
No requirements.
22+
| Name | Version |
23+
|------|---------|
24+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
25+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.0 |
2326

2427
## Providers
2528

2629
| Name | Version |
2730
|------|---------|
28-
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
31+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.0 |
2932

3033
## Modules
3134

3235
| Name | Source | Version |
3336
|------|--------|---------|
34-
| <a name="module_complete_sg"></a> [complete\_sg](#module\_complete\_sg) | ../../ | |
35-
| <a name="module_fixed_name_sg"></a> [fixed\_name\_sg](#module\_fixed\_name\_sg) | ../../ | |
36-
| <a name="module_ipv4_ipv6_example"></a> [ipv4\_ipv6\_example](#module\_ipv4\_ipv6\_example) | ../../ | |
37-
| <a name="module_main_sg"></a> [main\_sg](#module\_main\_sg) | ../../ | |
38-
| <a name="module_only_rules"></a> [only\_rules](#module\_only\_rules) | ../../ | |
39-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | |
37+
| <a name="module_complete_sg"></a> [complete\_sg](#module\_complete\_sg) | ../../ | n/a |
38+
| <a name="module_fixed_name_sg"></a> [fixed\_name\_sg](#module\_fixed\_name\_sg) | ../../ | n/a |
39+
| <a name="module_ipv4_ipv6_example"></a> [ipv4\_ipv6\_example](#module\_ipv4\_ipv6\_example) | ../../ | n/a |
40+
| <a name="module_main_sg"></a> [main\_sg](#module\_main\_sg) | ../../ | n/a |
41+
| <a name="module_only_rules"></a> [only\_rules](#module\_only\_rules) | ../../ | n/a |
42+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | n/a |
4043

4144
## Resources
4245

examples/complete/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,4 +399,3 @@ module "only_rules" {
399399
},
400400
]
401401
}
402-

examples/complete/outputs.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ output "security_group_description" {
2222
description = "The description of the security group"
2323
value = module.complete_sg.security_group_description
2424
}
25-

examples/complete/versions.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 0.13.1"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 3.0"
8+
}
9+
}
10+
}

examples/computed/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,23 @@ Note that this example may create resources which cost money. Run `terraform des
1717
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
1818
## Requirements
1919

20-
No requirements.
20+
| Name | Version |
21+
|------|---------|
22+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.0 |
2124

2225
## Providers
2326

2427
| Name | Version |
2528
|------|---------|
26-
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
29+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.0 |
2730

2831
## Modules
2932

3033
| Name | Source | Version |
3134
|------|--------|---------|
32-
| <a name="module_http_sg"></a> [http\_sg](#module\_http\_sg) | ../../modules/https-443 | |
33-
| <a name="module_mysql_sg"></a> [mysql\_sg](#module\_mysql\_sg) | ../../modules/mysql | |
35+
| <a name="module_http_sg"></a> [http\_sg](#module\_http\_sg) | ../../modules/https-443 | n/a |
36+
| <a name="module_mysql_sg"></a> [mysql\_sg](#module\_mysql\_sg) | ../../modules/mysql | n/a |
3437

3538
## Resources
3639

examples/computed/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,3 @@ module "mysql_sg" {
5252

5353
number_of_computed_ingress_with_source_security_group_id = 1
5454
}
55-

examples/computed/outputs.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ output "security_group_description" {
2222
description = "The description of the security group"
2323
value = module.mysql_sg.security_group_description
2424
}
25-

0 commit comments

Comments
 (0)