Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Terraform: aws default_tag not supported in root_block_device?

I am trying to use the default_tag available for the aws terraform provider.

Documentation:

From the doc, it says:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

This functionality is supported in all resources that implement tags, with the exception of the aws_autoscaling_group resource.

So, for all resources I have it works very well, except for aws_instance.root_block_device.

For example, I have:

provider "aws" {
  [...]
  default_tags {
    tags = {
      Env = prod
    }
  }
}

resource "aws_instance" "instance" {
  ami           = xxx
  instance_type = xxx
  
  root_block_device {
    volume_size           = xxx
    volume_type           = xxx
  }
}

The default tag Env = prod is correctly added to the instance itself, but not for the root_device_blockblock.

So I’m wondering if default_tag is supported for this. It’s true that the documentation says supported in all **resources** but root_block_device is only an argument of this resource, so maybe this is the problem?

I’m just looking for a kind of confirmation because the documentation is not very clear on this point.

Thank you

>Solution :

This is not supported yet. There are two issues are still open 1
2

but you can use this workaround solution

data "aws_default_tags" "example" {}
aws_instance {
  volume_tags = merge(aws_default_tags.example.default_tags, var.extra_tags)
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading