terraform-null-label
terraform-null-label copied to clipboard
Proposal: `prefix` output
Describe the Feature
I find it common that folks will utilize what I think of as the label's prefix (e.g. ${namespace}-${stage}-${environment}
) as a string interpolation prefix to some identifier that they want to create without building a full label.
Most of the time this is used as a crutch to avoid having to create a label module for each namable thing that you're working on. It could definitely be argued that this is a bad practice and that it shouldn't be done... but I've seen it enough now across multiple codebases that I know I'm not the only one who does it so figured this proposal was worth the discussion.
The proposal is to add a new output called prefix
that is simply all label components up until the name
component. e.g. ${namespace}-${stage}-${environment}
, ${namespace}-${stage}
, ${namespace}-${environment}
, etc.
I would need to look into the code more to determine how we would handle that in regards to the label ordering... but figured I could bring this up for discussion before coming up with a proper solution.
Use Case
This would enable not having to create this label prefix for ad-hoc usages and therefore dry up some terraform string interpolation code.
Alternatives Considered
Alternatives:
- Don't do this... I'd be fine to hear the feedback here say something along the lines of: Hey that should be considered bad practice and we don't want to support it.
- Create a
prefix
label that is only made up of the components that you want instead of outputting the prefix from more specific labels.