Skip to content

Commit 8098890

Browse files
authored
Merge pull request #21 from ministryofjustice/fix-auto-scaling-group-tags
Fix tags on auto scaling group.
2 parents f0880d1 + 093fb85 commit 8098890

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

modules/dns_dhcp_common/auto_scaling_group.tf

+25-13
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,27 @@ resource "aws_autoscaling_group" "auto_scaling_group" {
1111
vpc_zone_identifier = var.subnets
1212
wait_for_capacity_timeout = "20m"
1313

14-
tags = concat([var.tags], [{
14+
tag {
1515
key = "AmazonECSManaged"
1616
value = "AmazonECSManaged"
1717
propagate_at_launch = true
18-
}, {
18+
}
19+
20+
tag {
1921
key = "Name"
2022
value = var.prefix
2123
propagate_at_launch = true
22-
}])
24+
}
25+
26+
dynamic "tag" {
27+
for_each = var.tags
28+
29+
content {
30+
key = tag.key
31+
value = tag.value
32+
propagate_at_launch = true
33+
}
34+
}
2335

2436
timeouts {
2537
delete = "15m"
@@ -34,14 +46,14 @@ resource "aws_placement_group" "placement_group" {
3446
}
3547

3648
resource "aws_launch_configuration" "launch_configuration" {
37-
name_prefix = var.prefix
38-
image_id = data.aws_ami.server.id
39-
security_groups = [var.security_group_id]
40-
instance_type = "t2.medium"
41-
iam_instance_profile = aws_iam_instance_profile.ecs_instance_profile.id
42-
enable_monitoring = true
49+
name_prefix = var.prefix
50+
image_id = data.aws_ami.server.id
51+
security_groups = [var.security_group_id]
52+
instance_type = "t2.medium"
53+
iam_instance_profile = aws_iam_instance_profile.ecs_instance_profile.id
54+
enable_monitoring = true
4355
associate_public_ip_address = false
44-
user_data = <<DATA
56+
user_data = <<DATA
4557
Content-Type: multipart/mixed; boundary="==BOUNDARY=="
4658
MIME-Version: 1.0
4759
@@ -189,9 +201,9 @@ DATA
189201
}
190202

191203
data "aws_ami" "server" {
192-
most_recent = true
193-
name_regex = "^amzn-ami-.*-amazon-ecs-optimized$"
194-
owners = ["amazon"]
204+
most_recent = true
205+
name_regex = "^amzn-ami-.*-amazon-ecs-optimized$"
206+
owners = ["amazon"]
195207

196208
filter {
197209
name = "root-device-type"

0 commit comments

Comments
 (0)