> For the complete documentation index, see [llms.txt](https://isurus.gitbook.io/infrastructure-and-platform-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://isurus.gitbook.io/infrastructure-and-platform-notes/terraform-21/terraform-basics/03-terraform-variable-types.md).

# 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),

```
variable "a-list" {
  type    = list(any)
  default = [1, 2, 3]
}
```

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

Set(type),

```
variable "a-set" {
  type    = set(any)
  default = [1, 2, 3]
}
```

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),

```
variable "a-map" {
  type = map(string)
  default = {
    mykey = "my value"
  }
}
```

Object({ = , ...}),

Tuple(\[, ...]),
