Skip to content

Commit

Permalink
Fix tags on auto scaling group.
Browse files Browse the repository at this point in the history
Fix for the issue detailed here:
hashicorp/terraform-provider-aws#9049

We cannot merge a map of standard tags with an array of individual tag maps.

Co-authored-by: Andy Mitchell <me@themitchell.co.uk>
Co-authored-by: Neil Kidd <neil.kidd@madetech.com>
  • Loading branch information
3 people committed Sep 9, 2020
1 parent e1e1ca9 commit 093fb85
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions modules/dns_dhcp_common/auto_scaling_group.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 = <<DATA
user_data = <<DATA
Content-Type: multipart/mixed; boundary="==BOUNDARY=="
MIME-Version: 1.0
Expand Down Expand Up @@ -189,9 +201,9 @@ DATA
}

data "aws_ami" "server" {
most_recent = true
name_regex = "^amzn-ami-.*-amazon-ecs-optimized$"
owners = ["amazon"]
most_recent = true
name_regex = "^amzn-ami-.*-amazon-ecs-optimized$"
owners = ["amazon"]

filter {
name = "root-device-type"
Expand Down

0 comments on commit 093fb85

Please sign in to comment.