terratag
terratag copied to clipboard
Terratag does't apply tags to aws resources in nested blocks
Problem Statement: we've a resource "aws_instance" and corresponding tags in a terraform file already and a nested resources root_block_device with tags. When we apply terratag with extra_tags , it doesn't merge/apply to nested resource root_block_device.
Probably Solution:
Please implement an option in terratag cli to apply recursively so user has option to apply terratags in nested resources.
@indu-sharma1 can you please share an example?
@yaronya Here you go. TAGS doesn't apply to "root_block_device" block.
resource "aws_instance" "controllers" {
count = ( var.is_runtime ? ( var.is_ha ? 3 : 1) : 0)
ami = data.aws_ami.ec2_centos7_ami.image_id
instance_type = var.ctr_instance_type
key_name = aws_key_pair.main.key_name
vpc_security_group_ids = flatten([
aws_default_security_group.main.id,
aws_security_group.main.id
])
subnet_id = aws_subnet.main.id
user_data = data.template_file.cloud_data.rendered
root_block_device {
volume_type = "gp2"
volume_size = 400
delete_on_termination = true
tags = {
Name = "${var.project_id}-controller-${count.index + 1}-root-ebs"
Project = var.project_id
user = var.user
deployment_uuid = random_uuid.deployment_uuid.result
}
}
tags = {
Name = "${var.project_id}-controller-${count.index + 1}"
Project = var.project_id
user = var.user
deployment_uuid = random_uuid.deployment_uuid.result
}
}
Hi @indu-sharma1
So the expected behavior is for the root EBS volume to have both tags
attributes? or just the one under root_block_device
nested block?
Closing due to inactivity