-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
provider default tags aren't applied to root block devices #19890
Comments
Since it has been deemed that volume_tags is incompatible with root_block_device and ebs_block_device tag usage, perhaps it would be better to revisit default_tags interacting with those two? volume_tags are much more complicated as they apply to root_block ebs_block AND attached aws_ebs_volume resources, of which only the last get default_tags. |
Any plans to implement default_tags for ebs/root block devices? This is making tagging enforcement quite complicated and slowing our adoption of default_tags. |
For anyone dealing with this, I found a decent way around this issue without having to re-define tags: resource "aws_ec2_tag" "root_block_device" {
for_each = merge({ for name, value in aws_instance.example.tags_all :
name => value
if name != "Name" },
{ Name = "example-root" })
resource_id = aws_instance.example.root_block_device[0].volume_id
key = each.key
value = each.value
} I have allowed for a customized |
Do you have updates? Today we found out that 10% of our yearly AWS costs are unlabeled because of untagged EBS volumes when using the tags_all on the provider. |
We ended up fetching default tags via this datasource https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/default_tags and then merging them on root_block_device in Similar way like it's done in |
Is this being included in the 5.0.0 roadmap? This feature is really important for cost tracking. |
Has this been resolved? I am still seeing the default tags not being applied to the root device on aws version 5.6.2. |
I faced the same issue and second all the requests. Something like: data "aws_default_tags" "foo" {}
resource "aws_instance" "instance" {
volume_tags = data.aws_default_tags.foo.tags
. . .
} |
I am volunteering to look into this issue, issue number 6 of my 100 days of Terraform contributions challenge. |
You can select resource type and add tags by resource type, e.g. volume, in the GUI. The question is whether you can do this via API call. There is a CreateTags function https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/ec2#Client.CreateTags, so now the question becomes how to implement it as part of the instance creation process to a volume. Not going to comment anymore until this work is complete just saying it should be doable and I'm expecting to get this done within the next few days if not sooner. |
PR is pending, I'd like to have a quick conversation with you all about how terraform behavior will be handled with this one. Let's say we have the following code:
Because Name is a default tag. The fix would be to add the default tag to root block device tags, but I recognize this kind of defeats the purpose of what you all are looking for. What are your thoughts? Again, the apply will not successfully apply the change even though it would be a successful apply, it would be a permanent bug/feature. Just depends on what the community thinks. |
as it does everywhere else, it should merge default_tags with the root_block_device.tags of the same name taking precedence. |
This functionality has been released in v5.39.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
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. |
Community Note
Terraform CLI and Terraform AWS Provider Version
Affected Resource(s)
aws_instance
Terraform Configuration Files
Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.
Expected Behavior
ec2 instance root volumes should have default tags applied.
Actual Behavior
The ebs device created for the root volume did not get the default tags:
Steps to Reproduce
terraform apply
The text was updated successfully, but these errors were encountered: