resource "aws_vpc" "example" {
# ... other configuration ...
tags = {
Name = "MyVPC"
}
}
resource "aws_autoscaling_group" "asg_ec2" {
..........
..........
lifecycle {
create_before_destroy = true
}
tag {
key = "Name"
value = "awesome-app-server"
propagate_at_launch = true
}
tag {
key = "Role"
value = "server"
propagate_at_launch = true
}
dynamic "tag" {
for_each = var.tags
content {
key = tag.key
value = tag.value
propagate_at_launch = true
}
}
}
Normally all resources are tagged using a map as shown in #1 above
But all blogs and documentation always suggest tagging for ASG using a "list of maps" and not just a map as shown in #2 above.
Would like to understand why this deviation only for ASG?
TF docs states that tags
is depricated:
tags (Optional, Deprecated use tag instead) Set of maps containing resource tags. Conflicts with tag. See Tags below for more details.
So you shoudn't be using tags
as it is going to be removed in future.