From 093fb8536be53e91eeeaccfc035b7bcc8854c692 Mon Sep 17 00:00:00 2001 From: cait Date: Wed, 9 Sep 2020 14:01:45 +0100 Subject: [PATCH] Fix tags on auto scaling group. Fix for the issue detailed here: https://github.com/terraform-providers/terraform-provider-aws/issues/9049 We cannot merge a map of standard tags with an array of individual tag maps. Co-authored-by: Andy Mitchell Co-authored-by: Neil Kidd --- modules/dns_dhcp_common/auto_scaling_group.tf | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/modules/dns_dhcp_common/auto_scaling_group.tf b/modules/dns_dhcp_common/auto_scaling_group.tf index 0110c32c..e12ba3d3 100644 --- a/modules/dns_dhcp_common/auto_scaling_group.tf +++ b/modules/dns_dhcp_common/auto_scaling_group.tf @@ -11,15 +11,27 @@ resource "aws_autoscaling_group" "auto_scaling_group" { vpc_zone_identifier = var.subnets wait_for_capacity_timeout = "20m" - tags = concat([var.tags], [{ + tag { key = "AmazonECSManaged" value = "AmazonECSManaged" propagate_at_launch = true - }, { + } + + tag { key = "Name" value = var.prefix propagate_at_launch = true - }]) + } + + dynamic "tag" { + for_each = var.tags + + content { + key = tag.key + value = tag.value + propagate_at_launch = true + } + } timeouts { delete = "15m" @@ -34,14 +46,14 @@ resource "aws_placement_group" "placement_group" { } resource "aws_launch_configuration" "launch_configuration" { - name_prefix = var.prefix - image_id = data.aws_ami.server.id - security_groups = [var.security_group_id] - instance_type = "t2.medium" - iam_instance_profile = aws_iam_instance_profile.ecs_instance_profile.id - enable_monitoring = true + name_prefix = var.prefix + image_id = data.aws_ami.server.id + security_groups = [var.security_group_id] + instance_type = "t2.medium" + iam_instance_profile = aws_iam_instance_profile.ecs_instance_profile.id + enable_monitoring = true associate_public_ip_address = false - user_data = <