-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Overwrite Name tag? #138
Comments
What do you mean? Specify a different name tag in a specific resource, i.e. override the private subnet name to Application? The name tag is used from the input variable Name.
The way the tags are structured means that the name variable is always the winner. You could add name in the tags map but that would be superseded by the name key as part of the merge function. |
No I'm not aware of anything that would allow you to do that as per my previous comment on how merge works and the structure of the merged tag values. I looked to create a PR to reorder the tags so if required you could override the name on resources but I think you'd lose to much of the dynamic naming on resources. i.e. which AZ something is located in. |
I think if we change the order of tags being merged so that "Name" tag can be overwritten by a user for the resources it will be inconsistent for resources which are AZ aware and those which are not (for eg, public route table is not AZ aware, and private route table is AZ aware). |
My question is more why does the module even try to merge Name? If I have all my tags in one place like this: |
Sorry that it took me so long to reply to this one. I have been thinking about this and I think it will make most sense to implement the following logic:
So, for resource "aws_vpc" "this" {
tags = "${merge(map("Name", format("%s", var.name)), var.vpc_tags, var.tags)}"
} This way tags will be possible to override on all levels. |
Check #145 for the code changes |
Hi, @antonbabenko The only thing I can think of is that the name override is now a specific value. i.e. DATABASE. I think data lookups on single subnets would then break, because you couldn't filter on unique single resources. #145 I looked to do exactly what you've done a while ago. But I think it removes the dynamic AZ & count elements from the name. I'd personally add an additional tags for customisation. |
I'll add an example.
Creates three subnets, but there all called Application So this data resource fails because it's expecting 1 item to be returned. data "aws_subnet" "application" { This maybe an old data resource that was replaced with aws_subnet_ids, which works. But I still think you're losing useful information within tags. I'm wondering if there's a way to still add the ability to override the name but perhaps not loose the dynamic naming using AZ and count.index. |
I think it is a good idea to not put "Name" in AZ-aware tags (eg, For the piece of code you wrote I would recommend these changes: private_subnet_tags = {
Something-but-not-Name = "something"
}
tags = {
key = "value"
} |
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. |
Looking at: https://github.com/terraform-aws-modules/terraform-aws-vpc/blob/master/main.tf#L21 it seems that you automatically creates a tag called Name with a custom value, is there a way to overwrite that? I need a specific value for the Name tag.
The text was updated successfully, but these errors were encountered: