I am using below experimental block module in terraform settings block to use optional function .
experiments = [module_variable_optional_attrs]
I want to make variable urlMaps which is list(object) as optional . When I dont give urlMaps as a input to terraform.tfvars , I am expecting it send a null vaule. But it is giving exception mentioned below. If its not possible, is there any alternative to achieve this.
terraform.tfvars
urlMaps = [
{
hosts = ["example.com"]
paths = ["/image"]
service = "backend-service"
}
]
Variables.tf
variable "urlMaps" {
description = "Netowork endpoint group region"
type = optional(list(object({
hosts = list(string)
paths = list(string)
service = string
})))
}
Exception
│ Error: Invalid type specification
│
│ on lb/variables.tf line 30, in variable "urlMaps":
│ 30: type = optional(list(object({
│
│ Keyword "optional" is valid only as a modifier for object type attributes.
There are two posibilities:
urlMaps
.list(map)
, not list(object)
.