Reputation:
I want to tag all volumes at the time of EC2 Launch itself in Terraform. The same EC2 Tags should be applied to its Volumes at the time of creation. I dont want to enter tags separately for volumes. The Tags of EC2 should be applied to volume automatically.
I know we can do it in aws console when doing it manually. But when creating with terraform, please help me can we do it?
Thanks in advance.
Upvotes: 0
Views: 451
Reputation: 11259
You can use local values to store your tags and then use them with both tags
and volume_tags
like so
locals {
tags = {
Name = "my-instance"
Env = "production"
}
}
resource "aws_instance" "my-instance" {
...
tags = "${local.tags}"
volume_tags = "${local.tags}"
}
Upvotes: 1