From 5358969d82728c49498554f113a21b0bc9278623 Mon Sep 17 00:00:00 2001 From: Anton Babenko Date: Tue, 24 Nov 2020 10:02:31 +0100 Subject: [PATCH 1/7] fix: Updated supported Terraform versions (#173) --- .pre-commit-config.yaml | 20 +++++++++++++++-- README.md | 7 +++--- examples/complete-alb/README.md | 10 ++++++--- examples/complete-alb/main.tf | 35 ++++++++++++++++++----------- examples/complete-alb/variables.tf | 0 examples/complete-alb/versions.tf | 8 +++++++ examples/complete-nlb/README.md | 10 ++++++--- examples/complete-nlb/main.tf | 36 +++++++++++++++--------------- examples/complete-nlb/variables.tf | 0 examples/complete-nlb/versions.tf | 8 +++++++ examples/disabled/README.md | 34 ---------------------------- examples/disabled/main.tf | 12 ---------- versions.tf | 4 ++-- 13 files changed, 94 insertions(+), 90 deletions(-) create mode 100644 examples/complete-alb/variables.tf create mode 100644 examples/complete-alb/versions.tf create mode 100644 examples/complete-nlb/variables.tf create mode 100644 examples/complete-nlb/versions.tf delete mode 100644 examples/disabled/README.md delete mode 100644 examples/disabled/main.tf diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0285452..8677870 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,26 @@ repos: - repo: git://github.com/antonbabenko/pre-commit-terraform - rev: v1.27.0 + rev: v1.44.0 hooks: - id: terraform_fmt + - id: terraform_validate - id: terraform_docs + - id: terraform_tflint + args: + - '--args=--only=terraform_deprecated_interpolation' + - '--args=--only=terraform_deprecated_index' + - '--args=--only=terraform_unused_declarations' + - '--args=--only=terraform_comment_syntax' + - '--args=--only=terraform_documented_outputs' + - '--args=--only=terraform_documented_variables' + - '--args=--only=terraform_typed_variables' + - '--args=--only=terraform_module_pinned_source' + - '--args=--only=terraform_naming_convention' + - '--args=--only=terraform_required_version' + - '--args=--only=terraform_required_providers' + - '--args=--only=terraform_standard_module_structure' + - '--args=--only=terraform_workspace_remote' - repo: git://github.com/pre-commit/pre-commit-hooks - rev: v2.5.0 + rev: v3.3.0 hooks: - id: check-merge-conflict diff --git a/README.md b/README.md index bd6ae47..0a6ad5e 100644 --- a/README.md +++ b/README.md @@ -301,14 +301,14 @@ module "lb" { | Name | Version | |------|---------| -| terraform | >= 0.12.6, < 0.14 | -| aws | >= 2.54, < 4.0 | +| terraform | >= 0.12.6 | +| aws | >= 2.54 | ## Providers | Name | Version | |------|---------| -| aws | >= 2.54, < 4.0 | +| aws | >= 2.54 | ## Inputs @@ -322,6 +322,7 @@ module "lb" { | enable\_http2 | Indicates whether HTTP/2 is enabled in application load balancers. | `bool` | `true` | no | | extra\_ssl\_certs | A list of maps describing any extra SSL certificates to apply to the HTTPS listeners. Required key/values: certificate\_arn, https\_listener\_index (the index of the listener within https\_listeners which the cert applies toward). | `list(map(string))` | `[]` | no | | http\_tcp\_listeners | A list of maps describing the HTTP listeners or TCP ports for this ALB. Required key/values: port, protocol. Optional key/values: target\_group\_index (defaults to http\_tcp\_listeners[count.index]) | `any` | `[]` | no | +| https\_listener\_rules | A list of maps describing the Listener Rules for this ALB. Required key/values: actions, conditions. Optional key/values: priority, https\_listener\_index (default to https\_listeners[count.index]) | `any` | `[]` | no | | https\_listeners | A list of maps describing the HTTPS listeners for this ALB. Required key/values: port, certificate\_arn. Optional key/values: ssl\_policy (defaults to ELBSecurityPolicy-2016-08), target\_group\_index (defaults to https\_listeners[count.index]) | `any` | `[]` | no | | idle\_timeout | The time in seconds that the connection is allowed to be idle. | `number` | `60` | no | | internal | Boolean determining if the load balancer is internal or externally facing. | `bool` | `false` | no | diff --git a/examples/complete-alb/README.md b/examples/complete-alb/README.md index 74eecda..f2fabf1 100644 --- a/examples/complete-alb/README.md +++ b/examples/complete-alb/README.md @@ -17,14 +17,18 @@ Note that this example may create resources which cost money. Run `terraform des ## Requirements -No requirements. +| Name | Version | +|------|---------| +| terraform | >= 0.12.6 | +| aws | >= 2.54 | +| random | >= 2.0 | ## Providers | Name | Version | |------|---------| -| aws | n/a | -| random | n/a | +| aws | >= 2.54 | +| random | >= 2.0 | ## Inputs diff --git a/examples/complete-alb/main.tf b/examples/complete-alb/main.tf index ea93865..2250ac0 100644 --- a/examples/complete-alb/main.tf +++ b/examples/complete-alb/main.tf @@ -38,15 +38,15 @@ module "security_group" { egress_rules = ["all-all"] } -//module "log_bucket" { -// source = "terraform-aws-modules/s3-bucket/aws" -// version = "~> 1.0" -// -// bucket = "logs-${random_pet.this.id}" -// acl = "log-delivery-write" -// force_destroy = true -// attach_elb_log_delivery_policy = true -//} +# module "log_bucket" { +# source = "terraform-aws-modules/s3-bucket/aws" +# version = "~> 1.0" +# +# bucket = "logs-${random_pet.this.id}" +# acl = "log-delivery-write" +# force_destroy = true +# attach_elb_log_delivery_policy = true +# } module "acm" { source = "terraform-aws-modules/acm/aws" @@ -92,10 +92,10 @@ module "alb" { security_groups = [module.security_group.this_security_group_id] subnets = data.aws_subnet_ids.all.ids - // # See notes in README (ref: https://github.com/terraform-providers/terraform-provider-aws/issues/7987) - // access_logs = { - // bucket = module.log_bucket.this_s3_bucket_id - // } + # # See notes in README (ref: https://github.com/terraform-providers/terraform-provider-aws/issues/7987) + # access_logs = { + # bucket = module.log_bucket.this_s3_bucket_id + # } http_tcp_listeners = [ # Forward action is default, either when defined or undefined @@ -308,3 +308,12 @@ module "alb" { MyGlobalTargetGroupTag = "bar" } } + +######################### +# LB will not be created +######################### +module "lb_disabled" { + source = "../../" + + create_lb = false +} diff --git a/examples/complete-alb/variables.tf b/examples/complete-alb/variables.tf new file mode 100644 index 0000000..e69de29 diff --git a/examples/complete-alb/versions.tf b/examples/complete-alb/versions.tf new file mode 100644 index 0000000..fa3bbde --- /dev/null +++ b/examples/complete-alb/versions.tf @@ -0,0 +1,8 @@ +terraform { + required_version = ">= 0.12.6" + + required_providers { + aws = ">= 2.54" + random = ">= 2.0" + } +} diff --git a/examples/complete-nlb/README.md b/examples/complete-nlb/README.md index c90390f..a3b17e5 100644 --- a/examples/complete-nlb/README.md +++ b/examples/complete-nlb/README.md @@ -17,14 +17,18 @@ Note that this example may create resources which cost money. Run `terraform des ## Requirements -No requirements. +| Name | Version | +|------|---------| +| terraform | >= 0.12.6 | +| aws | >= 2.54 | +| random | >= 2.0 | ## Providers | Name | Version | |------|---------| -| aws | n/a | -| random | n/a | +| aws | >= 2.54 | +| random | >= 2.0 | ## Inputs diff --git a/examples/complete-nlb/main.tf b/examples/complete-nlb/main.tf index af10261..f99d954 100644 --- a/examples/complete-nlb/main.tf +++ b/examples/complete-nlb/main.tf @@ -25,15 +25,15 @@ data "aws_route53_zone" "this" { name = local.domain_name } -//module "log_bucket" { -// source = "terraform-aws-modules/s3-bucket/aws" -// version = "~> 1.0" -// -// bucket = "logs-${random_pet.this.id}" -// acl = "log-delivery-write" -// force_destroy = true -// attach_elb_log_delivery_policy = true -//} +# module "log_bucket" { +# source = "terraform-aws-modules/s3-bucket/aws" +# version = "~> 1.0" +# +# bucket = "logs-${random_pet.this.id}" +# acl = "log-delivery-write" +# force_destroy = true +# attach_elb_log_delivery_policy = true +# } module "acm" { source = "terraform-aws-modules/acm/aws" @@ -61,19 +61,19 @@ module "nlb" { vpc_id = data.aws_vpc.default.id - // Use `subnets` if you don't want to attach EIPs - // subnets = tolist(data.aws_subnet_ids.all.ids) + # Use `subnets` if you don't want to attach EIPs + # subnets = tolist(data.aws_subnet_ids.all.ids) - // Use `subnet_mapping` to attach EIPs + # Use `subnet_mapping` to attach EIPs subnet_mapping = [for i, eip in aws_eip.this : { allocation_id : eip.id, subnet_id : tolist(data.aws_subnet_ids.all.ids)[i] }] - // # See notes in README (ref: https://github.com/terraform-providers/terraform-provider-aws/issues/7987) - // access_logs = { - // bucket = module.log_bucket.this_s3_bucket_id - // } + # # See notes in README (ref: https://github.com/terraform-providers/terraform-provider-aws/issues/7987) + # access_logs = { + # bucket = module.log_bucket.this_s3_bucket_id + # } - // TCP_UDP, UDP, TCP + # TCP_UDP, UDP, TCP http_tcp_listeners = [ { port = 81 @@ -92,7 +92,7 @@ module "nlb" { }, ] - // TLS + # TLS https_listeners = [ { port = 84 diff --git a/examples/complete-nlb/variables.tf b/examples/complete-nlb/variables.tf new file mode 100644 index 0000000..e69de29 diff --git a/examples/complete-nlb/versions.tf b/examples/complete-nlb/versions.tf new file mode 100644 index 0000000..fa3bbde --- /dev/null +++ b/examples/complete-nlb/versions.tf @@ -0,0 +1,8 @@ +terraform { + required_version = ">= 0.12.6" + + required_providers { + aws = ">= 2.54" + random = ">= 2.0" + } +} diff --git a/examples/disabled/README.md b/examples/disabled/README.md deleted file mode 100644 index 41305cb..0000000 --- a/examples/disabled/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# Disabled creation of ALB example - -Configuration in this directory will not create ALB. - -## Usage - -To run this example you need to execute: - -```bash -$ terraform init -$ terraform plan -$ terraform apply -``` - -Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources. - - -## Requirements - -No requirements. - -## Providers - -No provider. - -## Inputs - -No input. - -## Outputs - -No output. - - diff --git a/examples/disabled/main.tf b/examples/disabled/main.tf deleted file mode 100644 index 37b75eb..0000000 --- a/examples/disabled/main.tf +++ /dev/null @@ -1,12 +0,0 @@ -provider "aws" { - region = "eu-west-1" -} - -########################################## -# LB WILL NOT be created by this example -########################################## -module "lb_disabled" { - source = "../../" - - create_lb = false -} diff --git a/versions.tf b/versions.tf index 3c1037e..a86d343 100644 --- a/versions.tf +++ b/versions.tf @@ -1,7 +1,7 @@ terraform { - required_version = ">= 0.12.6, < 0.14" + required_version = ">= 0.12.6" required_providers { - aws = ">= 2.54, < 4.0" + aws = ">= 2.54" } } From c3ab155dd3dda698bfc3779a7089239d8cb1dad0 Mon Sep 17 00:00:00 2001 From: Anton Babenko Date: Tue, 24 Nov 2020 10:02:53 +0100 Subject: [PATCH 2/7] Updated CHANGELOG --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e91cd9..2dce2d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ All notable changes to this project will be documented in this file. + +## [v5.10.0] - 2020-11-24 + +- fix: Updated supported Terraform versions ([#173](https://github.com/terraform-aws-modules/terraform-aws-alb/issues/173)) + + ## [v5.9.0] - 2020-09-11 @@ -257,7 +263,8 @@ All notable changes to this project will be documented in this file. - Initial commit -[Unreleased]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.9.0...HEAD +[Unreleased]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.10.0...HEAD +[v5.10.0]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.9.0...v5.10.0 [v5.9.0]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.8.0...v5.9.0 [v5.8.0]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.7.0...v5.8.0 [v5.7.0]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.6.0...v5.7.0 From 946f502788a4ecf1db2b0992b03fd194ccd99574 Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Sat, 20 Feb 2021 14:50:26 -0500 Subject: [PATCH 3/7] chore: update documentation based on latest `terraform-docs` which includes module and resource sections (#181) --- .gitignore | 33 +++++++++++++++++++++++++++++---- .pre-commit-config.yaml | 4 ++-- README.md | 15 ++++++++++++++- examples/complete-alb/README.md | 22 +++++++++++++++++++++- examples/complete-nlb/README.md | 18 +++++++++++++++++- 5 files changed, 83 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 4fa2920..397af32 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,29 @@ -.terraform -terraform.tfstate -*.tfstate* -terraform.tfvars +# Local .terraform directories +**/.terraform/* + +# Terraform lockfile +.terraform.lock.hcl + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log + +# Exclude all .tfvars files, which are likely to contain sentitive data, such as +# password, private keys, and other secrets. These should not be part of version +# control as they are data points which are potentially sensitive and subject +# to change depending on the environment. +*.tfvars + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Ignore CLI configuration files +.terraformrc +terraform.rc diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8677870..4963e57 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: git://github.com/antonbabenko/pre-commit-terraform - rev: v1.44.0 + rev: v1.46.0 hooks: - id: terraform_fmt - id: terraform_validate @@ -21,6 +21,6 @@ repos: - '--args=--only=terraform_standard_module_structure' - '--args=--only=terraform_workspace_remote' - repo: git://github.com/pre-commit/pre-commit-hooks - rev: v3.3.0 + rev: v3.4.0 hooks: - id: check-merge-conflict diff --git a/README.md b/README.md index 0a6ad5e..4367aad 100644 --- a/README.md +++ b/README.md @@ -310,6 +310,20 @@ module "lb" { |------|---------| | aws | >= 2.54 | +## Modules + +No Modules. + +## Resources + +| Name | +|------| +| [aws_lb_listener_certificate](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/lb_listener_certificate) | +| [aws_lb_listener_rule](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/lb_listener_rule) | +| [aws_lb_listener](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/lb_listener) | +| [aws_lb_target_group](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/lb_target_group) | +| [aws_lb](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/lb) | + ## Inputs | Name | Description | Type | Default | Required | @@ -359,7 +373,6 @@ module "lb" { | this\_lb\_dns\_name | The DNS name of the load balancer. | | this\_lb\_id | The ID and ARN of the load balancer we created. | | this\_lb\_zone\_id | The zone\_id of the load balancer to assist with creating DNS records. | - ## Authors diff --git a/examples/complete-alb/README.md b/examples/complete-alb/README.md index f2fabf1..828dff9 100644 --- a/examples/complete-alb/README.md +++ b/examples/complete-alb/README.md @@ -30,6 +30,27 @@ Note that this example may create resources which cost money. Run `terraform des | aws | >= 2.54 | | random | >= 2.0 | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| acm | terraform-aws-modules/acm/aws | ~> 2.0 | +| alb | ../../ | | +| lb_disabled | ../../ | | +| security_group | terraform-aws-modules/security-group/aws | ~> 3.0 | + +## Resources + +| Name | +|------| +| [aws_cognito_user_pool_client](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/cognito_user_pool_client) | +| [aws_cognito_user_pool_domain](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/cognito_user_pool_domain) | +| [aws_cognito_user_pool](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/cognito_user_pool) | +| [aws_route53_zone](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/data-sources/route53_zone) | +| [aws_subnet_ids](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/data-sources/subnet_ids) | +| [aws_vpc](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/data-sources/vpc) | +| [random_pet](https://registry.terraform.io/providers/hashicorp/random/2.0/docs/resources/pet) | + ## Inputs No input. @@ -50,5 +71,4 @@ No input. | this\_lb\_dns\_name | The DNS name of the load balancer. | | this\_lb\_id | The ID and ARN of the load balancer we created. | | this\_lb\_zone\_id | The zone\_id of the load balancer to assist with creating DNS records. | - diff --git a/examples/complete-nlb/README.md b/examples/complete-nlb/README.md index a3b17e5..6c15a8a 100644 --- a/examples/complete-nlb/README.md +++ b/examples/complete-nlb/README.md @@ -30,6 +30,23 @@ Note that this example may create resources which cost money. Run `terraform des | aws | >= 2.54 | | random | >= 2.0 | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| acm | terraform-aws-modules/acm/aws | ~> 2.0 | +| nlb | ../../ | | + +## Resources + +| Name | +|------| +| [aws_eip](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/eip) | +| [aws_route53_zone](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/data-sources/route53_zone) | +| [aws_subnet_ids](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/data-sources/subnet_ids) | +| [aws_vpc](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/data-sources/vpc) | +| [random_pet](https://registry.terraform.io/providers/hashicorp/random/2.0/docs/resources/pet) | + ## Inputs No input. @@ -50,5 +67,4 @@ No input. | this\_lb\_dns\_name | The DNS name of the load balancer. | | this\_lb\_id | The ID and ARN of the load balancer we created. | | this\_lb\_zone\_id | The zone\_id of the load balancer to assist with creating DNS records. | - From b72959e2863650d565118d0b0ed3942fd50354d6 Mon Sep 17 00:00:00 2001 From: Anton Babenko Date: Sat, 20 Feb 2021 20:51:35 +0100 Subject: [PATCH 4/7] Updated CHANGELOG --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dce2d6..24ceebb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ All notable changes to this project will be documented in this file. + +## [v5.11.0] - 2021-02-20 + +- chore: update documentation based on latest `terraform-docs` which includes module and resource sections ([#181](https://github.com/terraform-aws-modules/terraform-aws-alb/issues/181)) + + ## [v5.10.0] - 2020-11-24 @@ -263,7 +269,8 @@ All notable changes to this project will be documented in this file. - Initial commit -[Unreleased]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.10.0...HEAD +[Unreleased]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.11.0...HEAD +[v5.11.0]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.10.0...v5.11.0 [v5.10.0]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.9.0...v5.10.0 [v5.9.0]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.8.0...v5.9.0 [v5.8.0]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.7.0...v5.8.0 From 5daa93934396d2fde119a78fe00096705e3e0d3b Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Wed, 24 Feb 2021 05:59:44 -0500 Subject: [PATCH 5/7] chore: add ci-cd workflow for pre-commit checks (#183) --- .github/workflows/pre-commit.yml | 62 ++++++++++++++++++++++++++++++++ README.md | 10 +++--- examples/complete-alb/README.md | 14 ++++---- examples/complete-nlb/README.md | 10 +++--- 4 files changed, 79 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/pre-commit.yml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..73c2bee --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,62 @@ +name: Pre-Commit + +on: + pull_request: + push: + branches: + - master + +jobs: + getBaseVersion: + name: Get min/max versions + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Terraform min/max versions + id: minMax + uses: clowdhaus/terraform-min-max@v1.0.1 + outputs: + minVersion: ${{ steps.minMax.outputs.minVersion }} + maxVersion: ${{ steps.minMax.outputs.maxVersion }} + + preCommit: + name: Pre-commit check + runs-on: ubuntu-latest + needs: getBaseVersion + strategy: + fail-fast: false + matrix: + version: + - ${{ needs.getBaseVersion.outputs.minVersion }} + - ${{ needs.getBaseVersion.outputs.maxVersion }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Python + uses: actions/setup-python@v2 + + - name: Install Terraform v${{ matrix.version }} + uses: hashicorp/setup-terraform@v1 + with: + terraform_version: ${{ matrix.version }} + + - name: Install pre-commit dependencies + run: | + pip install pre-commit + curl -L "$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E "https://.+?-linux-amd64" | head -n1)" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/ + curl -L "$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/ + + - name: Execute pre-commit + # Run only validate pre-commit check on min version supported + if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }} + run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate + + - name: Execute pre-commit + # Run all pre-commit checks on max version supported + if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }} + run: pre-commit run --color=always --show-diff-on-failure --all-files diff --git a/README.md b/README.md index 4367aad..398db47 100644 --- a/README.md +++ b/README.md @@ -318,11 +318,11 @@ No Modules. | Name | |------| -| [aws_lb_listener_certificate](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/lb_listener_certificate) | -| [aws_lb_listener_rule](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/lb_listener_rule) | -| [aws_lb_listener](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/lb_listener) | -| [aws_lb_target_group](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/lb_target_group) | -| [aws_lb](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/lb) | +| [aws_lb](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb) | +| [aws_lb_listener](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener) | +| [aws_lb_listener_certificate](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener_certificate) | +| [aws_lb_listener_rule](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener_rule) | +| [aws_lb_target_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group) | ## Inputs diff --git a/examples/complete-alb/README.md b/examples/complete-alb/README.md index 828dff9..9ee648d 100644 --- a/examples/complete-alb/README.md +++ b/examples/complete-alb/README.md @@ -43,13 +43,13 @@ Note that this example may create resources which cost money. Run `terraform des | Name | |------| -| [aws_cognito_user_pool_client](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/cognito_user_pool_client) | -| [aws_cognito_user_pool_domain](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/cognito_user_pool_domain) | -| [aws_cognito_user_pool](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/cognito_user_pool) | -| [aws_route53_zone](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/data-sources/route53_zone) | -| [aws_subnet_ids](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/data-sources/subnet_ids) | -| [aws_vpc](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/data-sources/vpc) | -| [random_pet](https://registry.terraform.io/providers/hashicorp/random/2.0/docs/resources/pet) | +| [aws_cognito_user_pool](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cognito_user_pool) | +| [aws_cognito_user_pool_client](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cognito_user_pool_client) | +| [aws_cognito_user_pool_domain](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cognito_user_pool_domain) | +| [aws_route53_zone](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/route53_zone) | +| [aws_subnet_ids](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet_ids) | +| [aws_vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | +| [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | ## Inputs diff --git a/examples/complete-nlb/README.md b/examples/complete-nlb/README.md index 6c15a8a..fc83e66 100644 --- a/examples/complete-nlb/README.md +++ b/examples/complete-nlb/README.md @@ -41,11 +41,11 @@ Note that this example may create resources which cost money. Run `terraform des | Name | |------| -| [aws_eip](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/resources/eip) | -| [aws_route53_zone](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/data-sources/route53_zone) | -| [aws_subnet_ids](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/data-sources/subnet_ids) | -| [aws_vpc](https://registry.terraform.io/providers/hashicorp/aws/2.54/docs/data-sources/vpc) | -| [random_pet](https://registry.terraform.io/providers/hashicorp/random/2.0/docs/resources/pet) | +| [aws_eip](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eip) | +| [aws_route53_zone](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/route53_zone) | +| [aws_subnet_ids](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet_ids) | +| [aws_vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | +| [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | ## Inputs From dd2d660b65f0043e94b53baf6bc9799136d7a086 Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Wed, 3 Mar 2021 02:42:23 -0500 Subject: [PATCH 6/7] chore: align ci-cd static checks to use individual minimum Terraform versions (#185) * chore: align ci-cd static checks to use individual minimum Terraform versions * chore: bump min version of terraform for examples --- .github/workflows/pre-commit.yml | 72 ++++++++++++++++++++++++------- .pre-commit-config.yaml | 2 +- examples/complete-alb/README.md | 2 +- examples/complete-alb/versions.tf | 2 +- examples/complete-nlb/README.md | 2 +- examples/complete-nlb/versions.tf | 2 +- 6 files changed, 61 insertions(+), 21 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 73c2bee..efa5a77 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -7,14 +7,65 @@ on: - master jobs: - getBaseVersion: - name: Get min/max versions - runs-on: ubuntu-latest +# Min Terraform version(s) + getDirectories: + name: Get root directories + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install Python + uses: actions/setup-python@v2 + - name: Build matrix + id: matrix + run: | + DIRS=$(python -c "import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))") + echo "::set-output name=directories::$DIRS" + outputs: + directories: ${{ steps.matrix.outputs.directories }} + preCommitMinVersions: + name: Min TF validate + needs: getDirectories + runs-on: ubuntu-latest + strategy: + matrix: + directory: ${{ fromJson(needs.getDirectories.outputs.directories) }} steps: - name: Checkout uses: actions/checkout@v2 + - name: Install Python + uses: actions/setup-python@v2 + - name: Terraform min/max versions + id: minMax + uses: clowdhaus/terraform-min-max@v1.0.1 + with: + directory: ${{ matrix.directory }} + - name: Install Terraform v${{ steps.minMax.outputs.minVersion }} + uses: hashicorp/setup-terraform@v1 + with: + terraform_version: ${{ steps.minMax.outputs.minVersion }} + - name: Install pre-commit dependencies + run: pip install pre-commit + - name: Execute pre-commit + # Run only validate pre-commit check on min version supported + if: ${{ matrix.directory != '.' }} + run: + pre-commit run terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/* + - name: Execute pre-commit + # Run only validate pre-commit check on min version supported + if: ${{ matrix.directory == '.' }} + run: + pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf) + +# Max Terraform version + getBaseVersion: + name: Module max TF version + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 - name: Terraform min/max versions id: minMax uses: clowdhaus/terraform-min-max@v1.0.1 @@ -22,40 +73,29 @@ jobs: minVersion: ${{ steps.minMax.outputs.minVersion }} maxVersion: ${{ steps.minMax.outputs.maxVersion }} - preCommit: - name: Pre-commit check + preCommitMaxVersion: + name: Max TF pre-commit runs-on: ubuntu-latest needs: getBaseVersion strategy: fail-fast: false matrix: version: - - ${{ needs.getBaseVersion.outputs.minVersion }} - ${{ needs.getBaseVersion.outputs.maxVersion }} - steps: - name: Checkout uses: actions/checkout@v2 - - name: Install Python uses: actions/setup-python@v2 - - name: Install Terraform v${{ matrix.version }} uses: hashicorp/setup-terraform@v1 with: terraform_version: ${{ matrix.version }} - - name: Install pre-commit dependencies run: | pip install pre-commit curl -L "$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E "https://.+?-linux-amd64" | head -n1)" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/ curl -L "$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/ - - - name: Execute pre-commit - # Run only validate pre-commit check on min version supported - if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }} - run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate - - name: Execute pre-commit # Run all pre-commit checks on max version supported if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4963e57..188d38a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: git://github.com/antonbabenko/pre-commit-terraform - rev: v1.46.0 + rev: v1.47.0 hooks: - id: terraform_fmt - id: terraform_validate diff --git a/examples/complete-alb/README.md b/examples/complete-alb/README.md index 9ee648d..98b4122 100644 --- a/examples/complete-alb/README.md +++ b/examples/complete-alb/README.md @@ -19,7 +19,7 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| -| terraform | >= 0.12.6 | +| terraform | >= 0.12.26 | | aws | >= 2.54 | | random | >= 2.0 | diff --git a/examples/complete-alb/versions.tf b/examples/complete-alb/versions.tf index fa3bbde..3090b1c 100644 --- a/examples/complete-alb/versions.tf +++ b/examples/complete-alb/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 0.12.6" + required_version = ">= 0.12.26" required_providers { aws = ">= 2.54" diff --git a/examples/complete-nlb/README.md b/examples/complete-nlb/README.md index fc83e66..74d1bd0 100644 --- a/examples/complete-nlb/README.md +++ b/examples/complete-nlb/README.md @@ -19,7 +19,7 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| -| terraform | >= 0.12.6 | +| terraform | >= 0.12.26 | | aws | >= 2.54 | | random | >= 2.0 | diff --git a/examples/complete-nlb/versions.tf b/examples/complete-nlb/versions.tf index fa3bbde..3090b1c 100644 --- a/examples/complete-nlb/versions.tf +++ b/examples/complete-nlb/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 0.12.6" + required_version = ">= 0.12.26" required_providers { aws = ">= 2.54" From 6bbcb441debf53772279836f5bd25035fe6ae781 Mon Sep 17 00:00:00 2001 From: Anton Babenko Date: Wed, 3 Mar 2021 08:42:54 +0100 Subject: [PATCH 7/7] Updated CHANGELOG --- CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24ceebb..bd7c8f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ All notable changes to this project will be documented in this file. + +## [v5.12.0] - 2021-03-03 + +- chore: align ci-cd static checks to use individual minimum Terraform versions ([#185](https://github.com/terraform-aws-modules/terraform-aws-alb/issues/185)) +- chore: add ci-cd workflow for pre-commit checks ([#183](https://github.com/terraform-aws-modules/terraform-aws-alb/issues/183)) + + ## [v5.11.0] - 2021-02-20 @@ -269,7 +276,8 @@ All notable changes to this project will be documented in this file. - Initial commit -[Unreleased]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.11.0...HEAD +[Unreleased]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.12.0...HEAD +[v5.12.0]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.11.0...v5.12.0 [v5.11.0]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.10.0...v5.11.0 [v5.10.0]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.9.0...v5.10.0 [v5.9.0]: https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v5.8.0...v5.9.0