Type Constraints - Map

We will learn how to use Map type constraints in your Terraform project.

Map

A map is a set of values indexed by key name. You can give a map a type, which will be the type of the values.

Project example

Consider the following code:

Press + to interact
variable "my_map" {
type = map(number)
default = {
"alpha" = 2
"bravo" = 3
}
}
output "map" {
value = var.my_map
}
output "alpha_value" {
value = var.my_map["alpha"]
}

In this project, ...

Access this course and 1400+ top-rated courses and projects.