Interview Prep/Terraform/Variables, Locals, Outputs and Types

What are good uses of locals, and what are the limits?

IntermediateConceptVariables, Locals, Outputs and Types
Answer

Naming derived values, merging tag maps, building maps for for_each and avoiding repeated expressions. Locals can reference other locals but not form cycles. Overusing locals for a hundred small things makes code harder to read than a plain literal; if a value is configurable by the caller, make it a variable instead.

All Terraform questions Roadmap: Terraform

More on Variables, Locals, Outputs and Types