Variable Types

Terraform has two main types of variables,

  • Simple types

  • Complex types

It is not required to specify the type of the variables, but it is good to mention that.

Simple type variables,

Strings,

variable "a-string" {
    type = string
}

Number,

variable "a-number" {
    type = number
}

Boolean,

variable "a-bool" {
    type = bool
}

Complex type variables,

List(type),

A list will keep it's elements in order (ascending).

Set(type),

A set will not keep it's elements in order we put them in, rather it will sort them and remove all duplicates.

Map(type),

Object({ = , ...}),

Tuple([, ...]),

Last updated

Was this helpful?