What's going on with the "Include" block, how does it allows us to with keeping DRY (Don't Repeat Yourself), and what is it all about.
Similarly to many programming languages, include attributes are executed at the pre-processing stage. The specified target placed in the include block is fetched and slapped onto the current module. This mean that all attributes will be evaluated and expanded prior to the initialization of the module.
Instead of defining the entire locals
, provider
and remote backend
placed inside provider.hcl
again and again - we only define these setting and calls once, and using a single call from within our module (using the include
).
That allows for:
- Inheritance of all desired terragrunt files and values placed in of of the module's parent folders.
- Less prone to error.
- Dynamically configure values, paths, etc.
- Define once, reuse as much as you wish.