I was looking through the difference between map and object. My understanding is as follows :
A map can contain any type as long as all the elements are of the same type
variable "project_defaults" {
type = map(string)
default = {
project = "example_project"
region = "eu-west-1"
}
}
An object contains named attributes , each having their own type
variable "s3_buckets" {
type = object({
name = string
versioning = bool
s3_rules = list(map(any))
})
description = "List of maps for S3 buckets"
}
I have seen examples where map(object)
is used but am really unsure what the difference is compared to the type object
variable "s3_buckets" {
type = map(object({
name = string
versioning = bool
s3_rules = list(map(any))
}))
description = "List of maps for S3 buckets"
}
Am trying to make sense of when to make use of map(object)
as opposed to using object
. Syntax wise they look very similar but am unsure of the actual scenarios of when to use them.
map(string)
ormap(any)
with string, number, and bool values. – Plasterwork