type constraint
The type argument of a variable, such as string, number, bool, list(string), map(string) or object({...}), which rejects values of the wrong shape.
In more detail
Primitive types hold one value; collection types (list, set, map) hold many values of one type; structural types (object, tuple) describe a precise shape. A set has no order and no duplicates, which is why for_each accepts sets but not lists. The type any turns checking off and is best avoided.
Examples
type = map(string)type = object({ name = string, size = optional(number, 2) })Related terms
- input variable — A named, typed value a configuration or module takes from outside, declared in a variable block and read as var.<name>.
- tuple — An ordered, fixed-length group of values in which each position can have its own meaning and type.
- optional object attribute — Marking an attribute of an object type with optional() so callers may leave it out, with an optional default value.
Taught in
- Parameterising With Input Variables — Infrastructure as Code with Terraform
- Functions And Expressions In HCL — Infrastructure as Code with Terraform
- Writing A Custom Network Module — Infrastructure as Code with Terraform
- Calling Your Module And Passing Variables — Infrastructure as Code with Terraform
- Input Variables, Outputs, And Which Value Wins — HashiCorp Terraform Associate (004) Exam Prep
- Complex Types: Lists, Sets, Maps, Objects And Tuples — HashiCorp Terraform Associate (004) Exam Prep
- Count, For Each And Dynamic Blocks — HashiCorp Terraform Associate (004) Exam Prep