-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Support for Default Tags #13776
Comments
Hi @katbyte! Only comments on the schema or also on the proposal in general? Schema looks fine in my opinion, except for the
|
It's worth calling out that tags get really complicated fwiw - since (as I'm sure you know from the upstream issues) whilst tags look consistent in Azure, different resources have different limitations (some are lower-case only keys/values, others are an array rather than a dictionary etc) - which'll likely end up guiding the direction we take here. @aristosvo to your question about a dynamic resource group name, that wouldn't be supported in the Provider block (since Core doesn't support dynamic interpolation in the provider block at this time) - but all of these would likely be overridable on a per-resource level if we take this approach. |
Hi all, I'd like to share something about the implementation that we may need to introduce some computed properties in each resource to support default value in provider block. The reason is, take
This will cause problem when default value changes like the following, we don't know how to produce the plan: resource maybe use the default value and should be updated because default value updates; resource maybe not use the default value and no need to update.
Provider aws introduced a computed |
About
I have some updates, this is unblocked by a function called |
@ms-henglu that'd make sense if we made it only possible to specify these on the provider block, but that'd just cause conflicts with every resource specifying them inline otherwise. Unfortunately we can't make Tags Optional and Computed since it breaks the Policy-as-Code use-cases, instead we'll have to determine which tags should be specified at/filtered out from the Provider block when setting these into the state - which becomes more of a design question more than a technical one (although this also involves a non-trivial number of changes in the Provider too). |
Hi @tombuildsstuff ,
I thought that tags defined against the resource can override the whole default tags. But this may not be easy to just extend some tags.
Sounds good! How about But it would break the Policy-as-Code use-cases 🤔 |
@ms-henglu unfortunately you can't dynamically change the schema at runtime, so Location and Resource Group can't become O&C in some cases and Required in others.
I don't recall the specific details off the top of my head unfortunately - this was an issue in 1.x where this broke some policy-as-code tools in subtle ways - since this shouldn't have been computed in the first place, we fixed this in 2.0 and it's been fine since. |
How complete does this need to be? Are there constraints that could be documented to win for most resources. I'm not an expert in all azure resources, but so far I've found two exceptions (the first may be a class of exceptions):
Our use case could be more of an ignore use case for tags. We could apply values via policy, but then would want to tell terraform to ignore to policy driven tags. Like the case above, we'd still want to be able to override tag values for certain resources to add specificity. |
This comment was marked as off-topic.
This comment was marked as off-topic.
👋 hey folks We've spent some time digging into this and unfortunately it looks like this isn't going to be possible in it's current form. Whilst it's technically possible to add a As such to implement this we'd need to instead source this from an Environment Variable - and whilst that's technically possible we believe this could lead to user confusion when running on different machines with/without this variable defined (as the error would be "the field What this means is that unfortunately we won't be able to support Tags are unfortunately considerably more complicated than they may first appear - whilst most of the Resources within Resource Manager support Tags, not all Tags are created equally - with some API's having different limitations (either the number of tags available, the available casing on the tags, certain values which can't be set etc). What this means is that whilst we could look to support this on all applicable resources, the user experience would vary wildly, with some resources supporting it and others not. Were we to implement this on all resources and remove all applicable validation for Tags - users would be faced with indirect validation issues (similar to the Location/Resource Group problems described above). Whilst it would have been nice to have a clear divide as @etaham has suggested above by supporting this for Resource Manager and not Data Plane resources - unfortunately that doesn't appear to be possible with how tags work today. All that said, whilst we're currently not in a position to support this with the user experience it needs - I believe there is a path forward to supporting either One of the things we'll be working through over the coming months is to split the Create and Update function to allow the Whilst this may sound like an unrelated change, this'd ultimately solve the "policy as code" problem above, meaning that the Notably this won't fix the problem described above with the different possibilities for tags, we may be able to do something else at that point in time, with/without some additional upstream changes. However since this for the moment this isn't possible unfortunately I'm going to have to remove this from the 3.0 milestone, but I'm going to assign this to the 4.0 milestone so that we can take a look at this in the future. Thanks! |
Hope to see the |
Strongly support the feature. Implementation can be copy/pasted from the AWS one: https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags. It is great and developers won't be annoyed. Example: provider "azurerm" {
default_tags = {
app = "app-xx"
last_update = timestamp()
managed_by = "Terraform"
sources = "https://github.com/xxx/app-xx"
}
} |
Additionally to the "tag_keys_to_ignore" feature it would be useful if this could be based on prefix. For example a use case could be a tags are added based on config management i.e. ansible_xxxx with varying tag names. This would prevent having to manually list them as well over time if they expand the code block wouldn't have to be updated. |
We at @swisspost miss the feature to inherit tags to resources created by the azurerm provider. The AWS Provider has this feature since 3.38.0 (https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/resource-tagging#propagating-tags-to-all-resources). This has been done 3 Years ago would be very beneficial and appreciated if the azurerm provider was set on the same level as the aws provider :) |
Does anyone know when 4.0 is going to be released? This is a feature we really need at my organization. Has anyone discovered a workaround other than adding on a Thanks! |
@AMoghrabi I use an implementation where i have a
Then on a resource:
And then if I want to add something specific like a webapp version above the defaults, I merge them:
|
@danpetitt I guess we all use similar solution like yours, it's just it's too cumbersome. It would be nice to have default tags where applicable, and just add additional tags where needed. |
@danpetitt although I appreciate you sharing a workaround it is not solving the actual problem. The provider should be aware of which resources support tags and allow you to add them without unnecessary code lines. Currently one must check each and every resource for tag support first and then add the respective attribute to the resource. Default tags exist for ages on the AWS provider and it is so much better. |
This functionality is extremely valuable and something we have successfully utilized in AWS at a previous company. It automatically applies tags to every resource that supports tagging, generated by the provider. This feature is particularly beneficial when working with complex module hierarchies (modules within modules). By specifying tags in a single location, you streamline the tagging process across all nested resources. Having a similar capability in AzureRM would be incredibly useful and enhance resource management significantly. |
Same here, we are using the feature since years! for AWS. This issue is now open for three years. |
Also looking for that |
Bump. Need this for cloud-agnostic tag management. |
Also looking for that |
Could you please just add your thumbs-up to the top post, like the other 326 people did, so not everybody subscribed to this issue gets spammed with irrelevant emails? Thanks! |
any progress on this issue..? |
This is currently the most upvoted issue for the provider by over 175 votes at the time of this comment the next highest issue has only 193 votes. Just echoing what others have said is that AWS has provided this functionality for years and in addition is the sole reason my organization is putting more things in AWS over Azure. With ABAC with AWS default tags make things incredibly easy but since tags have to be manually applied per resource it is an absolute nightmare. |
I don't have a reference now, but I remember that the core problem is that each family of resources in Azure implemented tags in a different manner and the API is not unified, far from it. This would require quite some effort, or it would require that Azure API is refactored with an unified approach for tags. I would not expect much progress of this, unless there is a concerted community effort behind this. |
It's the same API for all resources |
Any news on the subject? needed feature indeed! |
Thank you for this documentation. In that case seems doable. But I still clearly remember that the difficulties are pretty big, although I am not sure why anymore. |
Community Note
Description
Investigate adding default values for location & resource_group to the provider block. This might also include tags depending on how feasible it is given the varying tag limitations of different resources/apis.
New or Affected Resource(s)
Potential Terraform Configuration
comments on the potential schema for this more then welcome!
The text was updated successfully, but these errors were encountered: