From dbadd04490b710e91d6b9c847c844f99da543acd Mon Sep 17 00:00:00 2001 From: Novikov Sergey Date: Thu, 21 Apr 2022 18:53:32 +0200 Subject: [PATCH] Update to aws provider to v4.0+ (#23) --- README.md | 4 ++-- modules/consul-cluster/README.md | 4 ++-- modules/consul-cluster/locals.tf | 2 +- modules/consul-cluster/main.tf | 37 ++++++++++++++++++------------ modules/consul-cluster/versions.tf | 2 +- modules/vault-cluster/README.md | 4 ++-- modules/vault-cluster/locals.tf | 2 +- modules/vault-cluster/main.tf | 27 ++++++++++++++-------- modules/vault-cluster/versions.tf | 2 +- versions.tf | 2 +- 10 files changed, 50 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index dfff0a7..214b746 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ module "aws_vault" { | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3 | +| [aws](#provider\_aws) | >= 4 | | [template](#provider\_template) | n/a | @@ -56,7 +56,7 @@ module "aws_vault" { | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13 | -| [aws](#requirement\_aws) | >= 3 | +| [aws](#requirement\_aws) | >= 4 | diff --git a/modules/consul-cluster/README.md b/modules/consul-cluster/README.md index 59e6f8c..041c4b2 100644 --- a/modules/consul-cluster/README.md +++ b/modules/consul-cluster/README.md @@ -17,13 +17,13 @@ rules. | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13 | -| [aws](#requirement\_aws) | >= 3 | +| [aws](#requirement\_aws) | >= 4 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3 | +| [aws](#provider\_aws) | >= 4 | | [null](#provider\_null) | n/a | ## Modules diff --git a/modules/consul-cluster/locals.tf b/modules/consul-cluster/locals.tf index b896795..17c0f5e 100644 --- a/modules/consul-cluster/locals.tf +++ b/modules/consul-cluster/locals.tf @@ -8,6 +8,6 @@ resource "null_resource" "tags_as_list_of_maps" { triggers = { "key" = element(keys(var.tags), count.index) "value" = element(values(var.tags), count.index) - "propagate_at_launch" = "true" + "propagate_at_launch" = true } } diff --git a/modules/consul-cluster/main.tf b/modules/consul-cluster/main.tf index 354bd4e..af3e8cf 100644 --- a/modules/consul-cluster/main.tf +++ b/modules/consul-cluster/main.tf @@ -14,21 +14,28 @@ resource "aws_autoscaling_group" "autoscaling_group" { health_check_grace_period = var.health_check_grace_period wait_for_capacity_timeout = var.wait_for_capacity_timeout - tags = concat( - [ - { - "key" = "Name" - "value" = var.cluster_name - "propagate_at_launch" = true - }, - { - "key" = var.cluster_tag_key - "value" = var.cluster_tag_value - "propagate_at_launch" = true - } - ], - local.tags_asg_format, - ) + dynamic "tag" { + for_each = concat( + [ + { + key = "Name" + value = var.cluster_name + propagate_at_launch = true + }, + { + key = var.cluster_tag_key + value = var.cluster_tag_value + propagate_at_launch = true + } + ], + local.tags_asg_format, + ) + content { + key = tag.value["key"] + value = tag.value["value"] + propagate_at_launch = tag.value["propagate_at_launch"] + } + } lifecycle { ignore_changes = [ diff --git a/modules/consul-cluster/versions.tf b/modules/consul-cluster/versions.tf index f0001a1..716ce4e 100644 --- a/modules/consul-cluster/versions.tf +++ b/modules/consul-cluster/versions.tf @@ -2,7 +2,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 3" + version = ">= 4" } } required_version = ">= 0.13" diff --git a/modules/vault-cluster/README.md b/modules/vault-cluster/README.md index b75cb08..f0ea953 100644 --- a/modules/vault-cluster/README.md +++ b/modules/vault-cluster/README.md @@ -37,13 +37,13 @@ machines. | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13 | -| [aws](#requirement\_aws) | >= 3 | +| [aws](#requirement\_aws) | >= 4 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3 | +| [aws](#provider\_aws) | >= 4 | | [null](#provider\_null) | n/a | ## Modules diff --git a/modules/vault-cluster/locals.tf b/modules/vault-cluster/locals.tf index b896795..17c0f5e 100644 --- a/modules/vault-cluster/locals.tf +++ b/modules/vault-cluster/locals.tf @@ -8,6 +8,6 @@ resource "null_resource" "tags_as_list_of_maps" { triggers = { "key" = element(keys(var.tags), count.index) "value" = element(values(var.tags), count.index) - "propagate_at_launch" = "true" + "propagate_at_launch" = true } } diff --git a/modules/vault-cluster/main.tf b/modules/vault-cluster/main.tf index 4b933fe..064f430 100644 --- a/modules/vault-cluster/main.tf +++ b/modules/vault-cluster/main.tf @@ -14,16 +14,23 @@ resource "aws_autoscaling_group" "autoscaling_group" { health_check_grace_period = var.health_check_grace_period wait_for_capacity_timeout = var.wait_for_capacity_timeout - tags = concat( - [ - { - "key" = "Name" - "value" = var.cluster_name - "propagate_at_launch" = true - } - ], - local.tags_asg_format, - ) + dynamic "tag" { + for_each = concat( + [ + { + key = "Name" + value = var.cluster_name + propagate_at_launch = true + } + ], + local.tags_asg_format, + ) + content { + key = tag.value["key"] + value = tag.value["value"] + propagate_at_launch = tag.value["propagate_at_launch"] + } + } lifecycle { ignore_changes = [ diff --git a/modules/vault-cluster/versions.tf b/modules/vault-cluster/versions.tf index f0001a1..716ce4e 100644 --- a/modules/vault-cluster/versions.tf +++ b/modules/vault-cluster/versions.tf @@ -2,7 +2,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 3" + version = ">= 4" } } required_version = ">= 0.13" diff --git a/versions.tf b/versions.tf index f0001a1..716ce4e 100644 --- a/versions.tf +++ b/versions.tf @@ -2,7 +2,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 3" + version = ">= 4" } } required_version = ">= 0.13"