From 6acc12f410d73e9ce8dd9aaa89d2b178f289dd3a Mon Sep 17 00:00:00 2001 From: Angelo Fenoglio Date: Wed, 13 Apr 2022 10:19:25 -0300 Subject: [PATCH 01/13] Remove empty provider configuration block warning --- bucket_replication.tf | 10 +++++----- config.tf | 11 ----------- main.tf | 8 ++++---- policy.tf | 8 ++++---- versions.tf | 8 ++++++-- 5 files changed, 19 insertions(+), 26 deletions(-) delete mode 100644 config.tf diff --git a/bucket_replication.tf b/bucket_replication.tf index 75f78e2..19e99c4 100644 --- a/bucket_replication.tf +++ b/bucket_replication.tf @@ -1,7 +1,7 @@ resource "aws_s3_bucket" "replication_bucket" { count = var.bucket_replication_enabled ? 1 : 0 - provider = aws.secondary_region + provider = aws.secondary bucket = format("%s-%s-%s-replica", var.namespace, var.stage, var.name) versioning { @@ -25,7 +25,7 @@ resource "aws_s3_bucket" "replication_bucket" { resource "aws_iam_role" "bucket_replication" { count = var.bucket_replication_enabled ? 1 : 0 - provider = aws.main_region + provider = aws name = format("%s-%s-%s-bucket-replication-module", var.namespace, var.stage, var.name) assume_role_policy = < Date: Wed, 13 Apr 2022 10:19:52 -0300 Subject: [PATCH 02/13] Update README --- README.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e5cd667..41e60b7 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,8 @@ We have a tfstate S3 Bucket per account | Name | Version | |------|---------| -| [aws.main\_region](#provider\_aws.main\_region) | ~> 3.0 | -| [aws.secondary\_region](#provider\_aws.secondary\_region) | ~> 3.0 | +| [aws](#provider\_aws) | ~> 3.0 | +| [aws.secondary](#provider\_aws.secondary) | ~> 3.0 | | [time](#provider\_time) | n/a | ## Modules @@ -120,12 +120,11 @@ No modules. # provider "aws" { region = "us-east-1 - alias = "main_region" } provider "aws" { region = "us-west-1" - alias = "secondary_region" + alias = "secondary" } # The following creates a Terraform State Backend with Bucket Replication enabled @@ -140,8 +139,8 @@ module "terraform_state_backend_with_replication" { bucket_replication_enabled = true providers = { - aws.main_region = aws.main_region - aws.secondary_region = aws.secondary_region + aws = aws + aws.secondary = aws.secondary } } @@ -159,8 +158,8 @@ module "terraform_state_backend" { # Notice that even though replication is not enabled, we still need to pass a secondary_region provider providers = { - aws.main_region = aws.main_region - aws.secondary_region = aws.main_region + aws = aws + aws.secondary = aws.secondary } } ``` From 051ef15407599685bbba4ba32aba9c36750e034e Mon Sep 17 00:00:00 2001 From: Angelo Fenoglio Date: Wed, 13 Apr 2022 10:47:50 -0300 Subject: [PATCH 03/13] Fix protocol in pre commit configuration urls --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 244e8e4..df95163 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ default_language_version: python: python3 repos: - - repo: git://github.com/pre-commit/pre-commit-hooks + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.2.0 hooks: - id: check-json @@ -17,7 +17,7 @@ repos: args: - --markdown-linebreak-ext=md - - repo: git://github.com/antonbabenko/pre-commit-terraform + - repo: https://github.com/antonbabenko/pre-commit-terraform rev: v1.43.0 hooks: - id: terraform_fmt From fc77f2d11a8c99eeacf4fa748a77b538cea69f59 Mon Sep 17 00:00:00 2001 From: Angelo Fenoglio Date: Mon, 2 May 2022 10:00:34 -0300 Subject: [PATCH 04/13] Update Makefile --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 41ed7cf..eecc78c 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ SHELL := /bin/bash MAKEFILE_PATH := ./Makefile MAKEFILES_DIR := ./@bin/makefiles -MAKEFILES_VER := v0.1.33 +MAKEFILES_VER := v0.2.1 PROJECT_SHORT := bb help: @@ -20,6 +20,6 @@ init-makefiles: ## initialize makefiles -include ${MAKEFILES_DIR}/circleci/circleci.mk -include ${MAKEFILES_DIR}/release-mgmt/release.mk --include ${MAKEFILES_DIR}/terraform14/terraform14-root-context.mk --include ${MAKEFILES_DIR}/terraform14/terraform14.mk --include ${MAKEFILES_DIR}/terratest14/terratest14.mk +-include ${MAKEFILES_DIR}/terraform1/terraform1-root-context.mk +-include ${MAKEFILES_DIR}/terraform1/terraform1.mk +-include ${MAKEFILES_DIR}/terratest1/terratest1.mk From 8ef4baac7d98c0a68e31fa2978409c5a0b7812ba Mon Sep 17 00:00:00 2001 From: Angelo Fenoglio Date: Mon, 2 May 2022 10:01:48 -0300 Subject: [PATCH 05/13] Add alias for primary provider --- README.md | 14 +++++++------- bucket_replication.tf | 6 +++--- main.tf | 8 ++++---- policy.tf | 8 ++++---- versions.tf | 3 +-- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 41e60b7..ce12fe3 100644 --- a/README.md +++ b/README.md @@ -35,16 +35,16 @@ We have a tfstate S3 Bucket per account | Name | Version | |------|---------| -| [terraform](#requirement\_terraform) | >= 0.13.2 | +| [terraform](#requirement\_terraform) | >= 1.0.9 | | [aws](#requirement\_aws) | ~> 3.0 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | ~> 3.0 | -| [aws.secondary](#provider\_aws.secondary) | ~> 3.0 | -| [time](#provider\_time) | n/a | +| [aws.primary](#provider\_aws.primary) | 3.75.1 | +| [aws.secondary](#provider\_aws.secondary) | 3.75.1 | +| [time](#provider\_time) | 0.7.2 | ## Modules @@ -139,7 +139,7 @@ module "terraform_state_backend_with_replication" { bucket_replication_enabled = true providers = { - aws = aws + aws.primary = aws aws.secondary = aws.secondary } } @@ -156,9 +156,9 @@ module "terraform_state_backend" { # By default replication is disabled but it shows below for the sake of the example bucket_replication_enabled = false - # Notice that even though replication is not enabled, we still need to pass a secondary_region provider + # Notice that even though replication is not enabled, we still need to pass a secondary provider providers = { - aws = aws + aws.primary = aws aws.secondary = aws.secondary } } diff --git a/bucket_replication.tf b/bucket_replication.tf index 19e99c4..f427e3d 100644 --- a/bucket_replication.tf +++ b/bucket_replication.tf @@ -25,7 +25,7 @@ resource "aws_s3_bucket" "replication_bucket" { resource "aws_iam_role" "bucket_replication" { count = var.bucket_replication_enabled ? 1 : 0 - provider = aws + provider = aws.primary name = format("%s-%s-%s-bucket-replication-module", var.namespace, var.stage, var.name) assume_role_policy = < Date: Mon, 2 May 2022 10:02:12 -0300 Subject: [PATCH 06/13] Update examples --- examples/s3-tfstate-backend-crr-ssl/config.tf | 2 +- examples/s3-tfstate-backend-crr-ssl/main.tf | 4 ++-- examples/s3-tfstate-backend-crr-vpce/config.tf | 2 +- examples/s3-tfstate-backend-crr-vpce/main.tf | 4 ++-- examples/s3-tfstate-backend-crr/config.tf | 2 +- examples/s3-tfstate-backend-crr/main.tf | 4 ++-- examples/s3-tfstate-backend/config.tf | 2 +- examples/s3-tfstate-backend/main.tf | 4 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/s3-tfstate-backend-crr-ssl/config.tf b/examples/s3-tfstate-backend-crr-ssl/config.tf index 78c9c58..a0cbe16 100644 --- a/examples/s3-tfstate-backend-crr-ssl/config.tf +++ b/examples/s3-tfstate-backend-crr-ssl/config.tf @@ -37,7 +37,7 @@ variable "profile" { # Backend Config (partial) # #=============================# terraform { - required_version = ">= 0.14.2" + required_version = ">= 1.0.9" required_providers { aws = "~> 3.0" diff --git a/examples/s3-tfstate-backend-crr-ssl/main.tf b/examples/s3-tfstate-backend-crr-ssl/main.tf index a49d4d0..0dba24d 100644 --- a/examples/s3-tfstate-backend-crr-ssl/main.tf +++ b/examples/s3-tfstate-backend-crr-ssl/main.tf @@ -15,7 +15,7 @@ module "terraform_state_backend" { tags = var.tags providers = { - aws.main_region = aws.main_region - aws.secondary_region = aws.secondary_region + aws.primary = aws.main_region + aws.secondary = aws.secondary_region } } diff --git a/examples/s3-tfstate-backend-crr-vpce/config.tf b/examples/s3-tfstate-backend-crr-vpce/config.tf index 72ea6e9..2a09cb0 100644 --- a/examples/s3-tfstate-backend-crr-vpce/config.tf +++ b/examples/s3-tfstate-backend-crr-vpce/config.tf @@ -37,7 +37,7 @@ variable "profile" { # Backend Config (partial) # #=============================# terraform { - required_version = ">= 0.14.2" + required_version = ">= 1.0.9" required_providers { aws = "~> 3.0" diff --git a/examples/s3-tfstate-backend-crr-vpce/main.tf b/examples/s3-tfstate-backend-crr-vpce/main.tf index aa9cfdf..909eeb4 100644 --- a/examples/s3-tfstate-backend-crr-vpce/main.tf +++ b/examples/s3-tfstate-backend-crr-vpce/main.tf @@ -17,8 +17,8 @@ module "terraform_state_backend" { tags = var.tags providers = { - aws.main_region = aws.main_region - aws.secondary_region = aws.secondary_region + aws.primary = aws.main_region + aws.secondary = aws.secondary_region } } diff --git a/examples/s3-tfstate-backend-crr/config.tf b/examples/s3-tfstate-backend-crr/config.tf index 78c9c58..a0cbe16 100644 --- a/examples/s3-tfstate-backend-crr/config.tf +++ b/examples/s3-tfstate-backend-crr/config.tf @@ -37,7 +37,7 @@ variable "profile" { # Backend Config (partial) # #=============================# terraform { - required_version = ">= 0.14.2" + required_version = ">= 1.0.9" required_providers { aws = "~> 3.0" diff --git a/examples/s3-tfstate-backend-crr/main.tf b/examples/s3-tfstate-backend-crr/main.tf index a49d4d0..0dba24d 100644 --- a/examples/s3-tfstate-backend-crr/main.tf +++ b/examples/s3-tfstate-backend-crr/main.tf @@ -15,7 +15,7 @@ module "terraform_state_backend" { tags = var.tags providers = { - aws.main_region = aws.main_region - aws.secondary_region = aws.secondary_region + aws.primary = aws.main_region + aws.secondary = aws.secondary_region } } diff --git a/examples/s3-tfstate-backend/config.tf b/examples/s3-tfstate-backend/config.tf index 78c9c58..a0cbe16 100644 --- a/examples/s3-tfstate-backend/config.tf +++ b/examples/s3-tfstate-backend/config.tf @@ -37,7 +37,7 @@ variable "profile" { # Backend Config (partial) # #=============================# terraform { - required_version = ">= 0.14.2" + required_version = ">= 1.0.9" required_providers { aws = "~> 3.0" diff --git a/examples/s3-tfstate-backend/main.tf b/examples/s3-tfstate-backend/main.tf index a49d4d0..0dba24d 100644 --- a/examples/s3-tfstate-backend/main.tf +++ b/examples/s3-tfstate-backend/main.tf @@ -15,7 +15,7 @@ module "terraform_state_backend" { tags = var.tags providers = { - aws.main_region = aws.main_region - aws.secondary_region = aws.secondary_region + aws.primary = aws.main_region + aws.secondary = aws.secondary_region } } From 04f851675a0fc421552e6163b2ba5a91efe0ed52 Mon Sep 17 00:00:00 2001 From: Angelo Fenoglio Date: Mon, 2 May 2022 10:15:07 -0300 Subject: [PATCH 07/13] Revert changes on autogenerated README section --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ce12fe3..bdbdf26 100644 --- a/README.md +++ b/README.md @@ -35,16 +35,16 @@ We have a tfstate S3 Bucket per account | Name | Version | |------|---------| -| [terraform](#requirement\_terraform) | >= 1.0.9 | +| [terraform](#requirement\_terraform) | >= 0.13.2 | | [aws](#requirement\_aws) | ~> 3.0 | ## Providers | Name | Version | |------|---------| -| [aws.primary](#provider\_aws.primary) | 3.75.1 | -| [aws.secondary](#provider\_aws.secondary) | 3.75.1 | -| [time](#provider\_time) | 0.7.2 | +| [aws.main\_region](#provider\_aws.main\_region) | ~> 3.0 | +| [aws.secondary\_region](#provider\_aws.secondary\_region) | ~> 3.0 | +| [time](#provider\_time) | n/a | ## Modules From 7636692af7943c224dfc0c4af7c46c1cf2ba6c42 Mon Sep 17 00:00:00 2001 From: Angelo Fenoglio Date: Mon, 2 May 2022 16:49:31 -0300 Subject: [PATCH 08/13] Update pre-commit terraform hook --- .circleci/config.yml | 2 +- .pre-commit-config.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6b64f92..1b038b1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,7 +42,7 @@ jobs: # # Install terraform-docs sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" - curl -Lo ./terraform-docs https://github.com/terraform-docs/terraform-docs/releases/download/v0.12.1/terraform-docs-v0.12.1-$(uname | tr '[:upper:]' '[:lower:]')-amd64 + curl -Lo ./terraform-docs https://github.com/terraform-docs/terraform-docs/releases/download/v0.16.0/terraform-docs-v0.16.0-$(uname | tr '[:upper:]' '[:lower:]')-amd64 chmod +x ./terraform-docs sudo mv ./terraform-docs /usr/local/bin/terraform-docs # diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index df95163..499218d 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: - --markdown-linebreak-ext=md - repo: https://github.com/antonbabenko/pre-commit-terraform - rev: v1.43.0 + rev: v1.71.0 hooks: - id: terraform_fmt - id: terraform_docs From 499ff259dce7ac0c0fa4ada15ad156d832ebc533 Mon Sep 17 00:00:00 2001 From: Angelo Fenoglio Date: Mon, 2 May 2022 17:46:17 -0300 Subject: [PATCH 09/13] Revert "Update pre-commit terraform hook" This reverts commit 7636692af7943c224dfc0c4af7c46c1cf2ba6c42. --- .circleci/config.yml | 2 +- .pre-commit-config.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1b038b1..6b64f92 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,7 +42,7 @@ jobs: # # Install terraform-docs sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" - curl -Lo ./terraform-docs https://github.com/terraform-docs/terraform-docs/releases/download/v0.16.0/terraform-docs-v0.16.0-$(uname | tr '[:upper:]' '[:lower:]')-amd64 + curl -Lo ./terraform-docs https://github.com/terraform-docs/terraform-docs/releases/download/v0.12.1/terraform-docs-v0.12.1-$(uname | tr '[:upper:]' '[:lower:]')-amd64 chmod +x ./terraform-docs sudo mv ./terraform-docs /usr/local/bin/terraform-docs # diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 499218d..df95163 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: - --markdown-linebreak-ext=md - repo: https://github.com/antonbabenko/pre-commit-terraform - rev: v1.71.0 + rev: v1.43.0 hooks: - id: terraform_fmt - id: terraform_docs From 6d1d2e6e9a26e47167d88c91e6bef1075cb1d2b7 Mon Sep 17 00:00:00 2001 From: Angelo Fenoglio Date: Tue, 3 May 2022 14:28:52 -0300 Subject: [PATCH 10/13] Fix secondary region --- examples/s3-tfstate-backend/config.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/s3-tfstate-backend/config.tf b/examples/s3-tfstate-backend/config.tf index a0cbe16..1cb48c6 100644 --- a/examples/s3-tfstate-backend/config.tf +++ b/examples/s3-tfstate-backend/config.tf @@ -24,7 +24,7 @@ variable "region" { variable "region_secondary" { type = string description = "AWS secondary Region the S3 replication bucket should reside in" - default = "us-east-2" + default = "eu-west-2" } variable "profile" { From 3c065e972c5b31c7602f0791be9b361b43eb830c Mon Sep 17 00:00:00 2001 From: Angelo Fenoglio Date: Tue, 3 May 2022 14:32:55 -0300 Subject: [PATCH 11/13] Fix primary region --- examples/s3-tfstate-backend/config.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/s3-tfstate-backend/config.tf b/examples/s3-tfstate-backend/config.tf index 1cb48c6..819f133 100644 --- a/examples/s3-tfstate-backend/config.tf +++ b/examples/s3-tfstate-backend/config.tf @@ -18,7 +18,7 @@ provider "aws" { variable "region" { type = string description = "AWS Region" - default = "us-east-1" + default = "eu-west-2" } variable "region_secondary" { From 46fe0c168bd6c8aecd05e309d70a62c203923579 Mon Sep 17 00:00:00 2001 From: Angelo Fenoglio Date: Tue, 3 May 2022 14:49:10 -0300 Subject: [PATCH 12/13] Revert "Fix secondary region" This reverts commit 6d1d2e6e9a26e47167d88c91e6bef1075cb1d2b7. --- examples/s3-tfstate-backend/config.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/s3-tfstate-backend/config.tf b/examples/s3-tfstate-backend/config.tf index 819f133..6a59ca3 100644 --- a/examples/s3-tfstate-backend/config.tf +++ b/examples/s3-tfstate-backend/config.tf @@ -24,7 +24,7 @@ variable "region" { variable "region_secondary" { type = string description = "AWS secondary Region the S3 replication bucket should reside in" - default = "eu-west-2" + default = "us-east-2" } variable "profile" { From 822ea24f81ade4a57fa8d71ee5bfb794435dc02b Mon Sep 17 00:00:00 2001 From: Angelo Fenoglio Date: Tue, 3 May 2022 14:49:21 -0300 Subject: [PATCH 13/13] Revert "Fix primary region" This reverts commit 3c065e972c5b31c7602f0791be9b361b43eb830c. --- examples/s3-tfstate-backend/config.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/s3-tfstate-backend/config.tf b/examples/s3-tfstate-backend/config.tf index 6a59ca3..a0cbe16 100644 --- a/examples/s3-tfstate-backend/config.tf +++ b/examples/s3-tfstate-backend/config.tf @@ -18,7 +18,7 @@ provider "aws" { variable "region" { type = string description = "AWS Region" - default = "eu-west-2" + default = "us-east-1" } variable "region_secondary" {