Reputation: 31520
This is due to crappy default behavior of the AWS provider wrt ASGs.
I had to resort to doing this: https://github.com/hashicorp/terraform/issues/15226
data "null_data_source" "asg-tags" {
count = "${length(keys(var.tags))}"
inputs = {
key = "${element(keys(var.tags), count.index)}"
value = "${element(values(var.tags), count.index)}"
propagate_at_launch = "true"
}
}
resource "aws_autoscaling_group" "my-group" {
....
tags = ["${data.null_data_source.asg-tags.*.outputs}"]
How do I do this with 0.12? I know there is better features for this sort of thing now so I should not have to use the null resource any more but I can't find any 0.12 examples of how to loop over a map and generate a new map.
Upvotes: 0
Views: 697
Reputation: 31520
I knew about dynamic blocks, but didnt think about it enough. This is much easier how. Can just have a list var and use dynamic block right in the resource
dynamic "tag" {
for_each = var.mytags
content {
key = tag.key
value = tag.value
propagate_at_launch = true
}
}
Upvotes: 1