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

How do list, set and map differ?

IntermediateConceptVariables, Locals, Outputs and Types
Answer

A list(T) is ordered and allows duplicates and is indexed by position. A set(T) is unordered with unique values and has no index, so you cannot do set[0]. A map(T) has string keys with values of one type. for_each accepts a map or set of strings; convert lists with toset().

All Terraform questions Roadmap: Terraform

More on Variables, Locals, Outputs and Types