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

What is the difference between locals and variables?

BeginnerConceptVariables, Locals, Outputs and Types
Answer

Variables are inputs set by the caller. Locals are named expressions internal to the module, computed from variables, resources and other locals. Use locals to avoid repeating an expression or to give a derived value a name, like local.name_prefix = "${var.app}-${var.env}"; do not use them as disguised inputs.

All Terraform questions Roadmap: Terraform

More on Variables, Locals, Outputs and Types