Terraform

How to define an input variable which is an object with attributes "model" (string), "color" (string), year (number)?

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

variable "car_model" {
  description = "Car model object"
  type        = object({
    model   = string
    color   = string
    year    = number
  })
}

Note: you can also define a default for it.