Loading...
Loading...
I'm not sure what the issue is here, but consider this example: Module `example`: ```hcl variable "example" { type = map( object({ nested_a = object({ nested_b = list( object({ problem_variable = any }) ) }) }) ) default = {} } resource "null_resource" "example" { for_each = var.example } ``` Note the `any`. Now, assume this top-level module: ``` variable "example" { type = map( object({ name = string nested_a = object({ nested_b = list( object({ problem_variable = any }) ) }) }) ) } module "example" { source = "./example" example = var.example } ``` Now we define a variable `example`, and run `plan`: ```hcl example = { "example a" = { nested_a = { nested_b = [ { problem_variable = {foo = "bar"} } ] } } } ``` ```bash Terraform will perform the following actions: # module.example.null_resource.example["example a"] will be created + resource "null_resource" "example" { + id = (known after apply) } Plan: 1 to add, 0 to change, 0 to destroy. ``` Works fine. Now I add a second entry to the map: ``` "example b" = { name = "foo" nested_a = { nested_b = [ { problem_variable = { foo = "baz" } } ] } } ``` This too works fine: ``` Terraform will perform the following actions: # module.example.null_resource.example["example a"] will be created + resource "null_resource" "example" { + id = (known after apply) } # module.example.null_resource.example["example b"] will be created + resource "null_resource" "example" { + id = (known after apply) } ``` But now let's say I have an entry, `example_c`, where there is no list of values: ``` "example c" = { nested_a = { nested_b = [] # EMPTY. } } ``` I now get this error: ``` Error: Invalid value for module argument on main.tf line 17, in module "example": 17: example = var.example The given value is not suitable for child module variable "example" defined at example/main.tf:1,1-19: object is required. ``` So it appears it wants at least one object in the list (that matches the type of the other objects, of course). Is this by design? Seems wrong ...
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.