Hi there,
$ terraform -v
Terraform v0.7.4
Please list the resources as a list, for example:
This is an ASG defined in a module with some default tags:
resource "aws_autoscaling_group" "asg" {
name = "${var.env}-${var.cell}-${var.app}"
launch_configuration = "${aws_launch_configuration.lc.name}"
.
.
.
tag {
key = "Name"
value = "${var.env}-${var.app}"
propagate_at_launch = true
}
tag {
key = "app"
value = "${var.env}-${var.app}"
propagate_at_launch = true
}
.
.
.
I'd like to be able to pass this module some extra tags to add to the ASG. for example if I have a couple of different stacks using this module and they both require these default tags but then one of them requires some additional tags. Is this available already? I've done a fair amount of googling on this but cannot find anything on it.
It seems that because each tag is added individually rather than a list of tags that I can't add to the list. Is there a workaround for this or can we get it implemented?
Thanks,
Ryan
Been thinking a little more about this this evening and looking at the way the autoscaling group is implemented in TF I think that it would be very difficult to add in extensible tags like I want. Would a potential solution be to create a new resource type call something like aws_autoscaling_tag which could take in the name of the scaling group, the key and value of the tag. Then apply the tag to the existing group?
I have been playing around with the overrides feature built in to terraform to try and achieve this. But it would appear that I cannot override a resource in a module from the root, is this correct?
+1
I think this should be implemented and standardized as in aws_instance resource.
So, let's compare ASG and single EC2 instance tag description in terraform:
resource "aws_autoscaling_group" "bar" {
...
tag {
key = "foo"
value = "bar"
propagate_at_launch = true
}
tag {
key = "lorem"
value = "ipsum"
propagate_at_launch = false
}
}
resource "aws_instance" "bar" {
...
tags = {
Name = "HelloWorld"
foo = "bar"
}
It would be great to have standard description of tags, smth like
resource "aws_autoscaling_group" "bar" {
...
tags = {
Name = {
value = "my-name"
propagate_at_launch = true
},
MySecondTag = {
value = "tag2"
propagate_at_launch = false
}
}
}
In this way tags for ASG can be described in variables.tf and overridden later when module reused.
Or even simpler:
split those two tags to two different arguments, like:
resource "aws_autoscaling_group" "bar" {
...
tags_propagated = {
Name = "my-name"
AnotherTagForInstances = "foo"
}
tags = {
MyTagForASGNotPropagted = "baz"
}
}
@mitchellh , could you take a look on this (above)
It would be awesome to have this. Is there any plans to implement it?
Seriously... is it going to be implemented? Lack of this functionality affects flexibility in writing modules in a hard way
Is there any news on this? Being able to set tags in the same way as other resources would be a great help for us.
I think this will issue will resolve it, which is slated for the next release: https://github.com/hashicorp/terraform/pull/13574/
That issue is good, but I can't think of any way with interpolations to let a module accept a map of tags (to set on VPC/segurity groups say) and to also apply those to ASG-created instances.
i.e. Is it possible to go from {"x": "y", "z": "w"} to [{"Key": "x", "Value": "y", "PropagateAtLaunch": true},{"Key": "z", "Value": "w", "PropagateAtLaunch": true}] using just pure HCL/interpolations?
I had to write a script to get around this. Feel free to use it here: https://github.com/carlosonunez/terraform_asg_tag_creator
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
Or even simpler:
split those two tags to two different arguments, like: