-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
feat: Add variable to set custom tags on cluster primary SG #2577
feat: Add variable to set custom tags on cluster primary SG #2577
Conversation
@ivankatliarchuk provider tags have been removed due to the numerous issues they created. Modules shouldn't need to do anything special with provider tags - they should just work and propagate down to the supported resources created by the provider |
@bryantbiggs I got your point. But this security group is created by EKS itself, how you expect For exact reason there is a line
|
I don't know what you mean by But you can add any tags you would like via the |
I mean, that the resource is created outside the |
I might not explaining correctly, but the reason why the resource exists (in my understanding)
Is because
|
correct - I added this resource so that tags are propagated to the security group that the EKS service created since Terraform did NOT create it. if you wish to add any additional tags to this security group you can provide them via |
A rough example of using the provider "aws" {
default_tags {
tags = {
team = "foobar"
}
}
}
module "eks" {
...
cluster_tags = {
team = "foobar" # This causes a conflict with default_tags
}
} The default_tags configuration in the provider is used to tag all resources with I believe this is where the below error arises
|
again - we are not taking on any additional work to mitigate the current deficiencies of the provider default tags and instead you should defer to the upcoming changes hashicorp/terraform-provider-aws#29747 |
Specifically the |
I'll leave it here if someone is going to have a similar issue. The case is only partially related. How you expect a resource Example tagging, in yaml for simplicity
With the input above, SG will only get following tags set
If we decide to merge default and cluster tags, below input is not going to work at least in meantime. There is a plan to support duplicates, but why would we even duplicate tags.
So the options left
|
Correct
I don't expect anything - I am simply working with what exists. The EKS service creates this security group and its outside of Terraform's control - which is why the tag resource was added. If you wish to add tags to this security group, you can use |
Regarding the last question you answered, currently there is no feature in AWS provider to overwrite tags and avoid error because of duplication.
You removed all references of So you say you are simply working with what exists, but you are actually working based on a provider feature that may be released sometime in the future and we are not sure it will actually solve the problem. And even when that solution solved the duplication error it will be weird to have default tags in the provider and at the same time set the variable |
I actually tested it, it works for the intended purpose, you can set whatever tags you want to the cluster primary group. If you check my changes, I'm not doing anything with the provider tags or anything like that. I just added a variable so you can add tags to the cluster primary SG not using Does this change needs to be there forever? No, once the provider supports to overwrite tags instead of throwing a duplication error this variable can be removed or refactored or have a discussion again. But now, the situation is, I have a terraform project using your module but also creating other resources and I'd like to have every resource tagged with some default tags, how do we do that? setting default tags in the provider. But resources not created by terraform, like the cluster primary SG are not picking up those tags for obvious reasons. And the solutions you are giving me to add the default tags to those resources too are:
In conclusion, your module is not providing any way to apply the default tags that are being applied to the rest of the resources to resources like the cluster primary SG. And I get it, that SG is created by EKS, not by terraform but it is indirectly created by your module because the SG gets created when you create an EKS cluster which is why we your module, to create EKS clusters. |
When you say:
It sounds like you know some scenario when my change won't work. If that is the case and I'm missing something, please let me know, show me which is that use case and how the change does not work and I can learn something. If it is that you don't think that this change should be in the module, please explain your reasons without suggesting options that we already tried, and we are telling you that generate errors or options that are based on features not available yet. I know that it is your module, and at end you'll do with it what you want, but if you offer something open source expecting the community to use it, it would be good that you explain your decisions and to be open to community use cases that you might not have thought about. We are presenting here a use case that is clearly not supported by the module and we expect maintainers to work with us in a solution |
I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Description
The purpose of this change is to add the possibility to set additional tags to the cluster primary security group.
Motivation and Context
With version 19,
aws_default_tags
were removed because it may lead to update conflicts and should be managed by the user in the provider configuration. I agree with this and in the projects where I work, we are setting all the default tags in the provider. But when upgrading from version 18 to version 19 this cause the deletion of several tags from the cluster primary security group that are desired to have.Exploring the code, I found this:
Considering we are setting default tags in the provider, with the previous configuration, the cluster primary security group was getting the default tags. Now, it is only receiving tags from
var.tags
andvar.cluster_tags
so if I want the cluster primary security group to have the default tags, I only can do it using those variables because this SG is not created by the module it does not get the tags from the provider. The problem of usingvar.tags
andvar.cluster_tags
is that those variables are also applied to the other resources in the module, causing terraform to throw this error.With this new variable it would be possible to assign tags to the cluster primary security group only, without impacting other resources.
Breaking Changes
None known.
How Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/*
projectspre-commit run -a
on my pull request