bridgecrewio / yor

Extensible auto-tagger for your IaC files. The ultimate way to link entities in the cloud back to the codified resource which created it.
https://www.yor.io
Apache License 2.0
827 stars 123 forks source link

Feature request: support prefixes for generated tags #292

Closed jgrumboe closed 1 year ago

jgrumboe commented 2 years ago

Is your feature request related to a problem? Please describe. Yes, the problem is described in this blog post https://gsd.fundapps.io/how-we-make-yor-work-with-terraform-caller-and-child-modules-22216afd775d where the author wants to tag remote module resources and the module-calling resource. Therefore he needs to remap the "incoming" tags from the caller.

Describe the solution you'd like Yor should support a --prefix (or similar) option which would generate prefixed tags. This way one could run yor tag -d . --prefix "module_" for the module terraform code and would get module_yor_trace, module_git_commitand so on. The caller terraform code would run yor tag -d . as usual. No remapping is needed as the caller tags won't overwrite module tags.

Describe alternatives you've considered The alternative is already described in the blog post mentioned to remap values.

jgrumboe commented 2 years ago

@nimrodkor @tsmithv11 @rotemavni WDYT?

mik3h0 commented 2 years ago

Hey, author of that medium post here 👋 FWIW I really like this feature request, definitely less work than my solution (for the user anyway)

tsmithv11 commented 2 years ago

Thanks, @jgrumboe! We'd appreciate a contribution for this!

ChanochShayner commented 1 year ago

Hey @jgrumboe :) I've just opened a PR for this enhancement (sorry @kartikp10 that I stole it from you 🤓), I'm thinking now about the merge tags use case - If a user with existing tags starts to use the new tag-prefix flag:

Thanks FYI @tsmithv11

jgrumboe commented 1 year ago

Hi @ChanochShayner , cool you jumped on it 🙂

That's a good question about how to deal with existing yor tags. I didn't think about it as I would be the "newjoiner" and wouldn't have any existing yor tags.

I think the easiest option development-wise would be 3) adding the prefixed tags to the existing ones, but that would lead to a lot of work for the users to get rid of the old tags. Maybe additional command-line parameters like "--override" or "--merge" could be implemented to give the user the option to select their fit.

ChanochShayner commented 1 year ago

@jgrumboe @mik3h0 I've just merged the PR 🙂