-
-
Notifications
You must be signed in to change notification settings - Fork 317
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: adds support for optional root_module tag #144
feat: adds support for optional root_module tag #144
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @gberenice a couple of comments for you!
} | ||
|
||
# Remove null values from tags_context. Required due to `root_module` that can be null. | ||
tags_context_clean = { for k, v in local.tags_context : k => v if v != null } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @gberenice just a thought - if you set root_module
to ""
instead of null (when it's not enabled), you don't need this line. Perhaps this would be more in line with the treatment of the other variables, as done when setting normalized_labels
?
@@ -96,6 +96,8 @@ locals { | |||
stage = local.formatted_labels["stage"] | |||
name = local.formatted_labels["name"] | |||
|
|||
root_module = var.root_module_tag_enabled ? basename(path.cwd) : null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that using this with terragrunt doesn't have the intended output. It will output the temporary directory name from within the .terragrunt-cache/
dir. This might be relevant because this module is used in lots of scenarios, not just within the atmos workflow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @joe-niland , this should not be used in the module b/c it might not work in all scenarios
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joe-niland didn't know you were using Terragrunt! Good to know -- may need to ping you at some point in the coming weeks 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gberenice Thank you for this PR.
As you may know, null-label
is central to the Cloud Posse architecture, which unfortunately makes even the tiniest change a big deal. I will leave this PR open for a while for discussion, but I expect to reject it as "won't do". As you pointed out, you can achieve the same effect with the introspection.mixin.tf
or by deploying your own, modified context.tf
in your own root modules. That path allows you to control your environment without affecting other users of the Cloud Posse Terraform modules.
One concrete problem with your proposal is that basename
will not necessarily give you the name of the root module. For example, most of terraform-aws-components
's eks
modules are under eks/
, so we would want the root module name to be something like eks/cluster
or eks/alb-controller
.
I suggest you work things out with a solution that does not involve a change to null-label
and once that solution is proven, you can propose the feature as an enhancement to null-label
and we can consider it for the v2 release.
@joe-niland @aknysh @Nuru thanks a lot for your reviews, these are valid points. I need to research the case with Terragrunt. |
@Nuru I get your point on not wanting to merge this as it stands, but if we can I'd like to figure out what we'd want to see here explicitly to move this forward. We see this as being worth a future revision of null-label, and with the many new label based modules that are coming out I personally think this could be a good differentiator. Keeping this information inside of private forks of Couple explicit items I could see as additional functionality here that would serve all cases:
Keeping the default of this functionality as disabled is obviously critical as this likely doesn't make sense in all terraform usecases. Thoughts on the above? We would be happy to dogfood these ideas internally at Masterpoint and resurface here via this PR at a later date if those sound like potentially useful and mergable enhancements to this functionality. |
@Gowiem Thank you for your proposal, into which you have obviously put a lot of thought. I feel you may have overlooked the fact that For one, you can create your own mixin that sets your custom tags however you like and then adds them to the AWS provider Alternately, you can create a custom version of tags = var.tags with tags = merge(local.introspection_tags, var.tags) and populate If you develop your custom |
@gberenice @Gowiem Here is another way to achieve your goals. In your root modules, in addition to the current root-module-tag_override.tfmodule "this" {
tags = merge(var.tags, {
"Root_module" = basename(abspath(path.module))
})
} Let me know what you think. Unless I hear an objection, I plan to close this PR with this as the recommended alternative. |
@Nuru thank you. I think we'll figure out the way that works best for our needs based on your advice and our analysis. Much appreciate the feedback from all of you. |
@Nuru yeah, understood across all. I still believe this has value for the overall community if this functionality were included, but I'd probably be belaboring the point in pushing that further. We'll take this internally and go from there. Thanks for the thoughtful response and solution engineering, it is appreciated! 👍 |
what
root_module
that will be output along with other context tags if the corresponding bool variable is set totrue
. A similar feature is introduced in introspection.mixin.tf.why
context.tf
and avoid updating additional tags for every child module or resource.references