I’ve been using the default_tags
of aws provider for a while, super practical and saves so much code. I noticed that many submodules I write have all resources add the same tags to the default tags, by setting them in the tags
property of the resource.
So I’m wondering if there is a way for a submodule to “extend” the parent’s aws provider that it inherits, with additional default tags, so that I could remove the tags
property form almost every resource of every submodule.
Sounds like defining provider aliases in submodule is anti pattern, so approach of adding an aws provider block in submodule is no-go.
So the only other way I see is to define additional providers in the root module. But
- this is a fair bit of work: if your root module uses N submodules which each use M sub-submodules, you need N*M provider aliases!
- this seems to violate treating modules as black boxes: a submodule should be able to “customize” what it inherits (at least in terms of tags), without affecting the parent; a root module should not know details of a submodule.
Which technically means submodules should have their own providers, with syntax on each provider to specify whether it should inherit from one of the “passed in” providers, or be a “clean slate”.
Is there a better solution?