Closed
Description
This works fine
$ terraform console
> length(list("", "1", "")
3
But if you do
locals {
list_of_things = [
"${a_resource.one.id}",
"${a_resource.two.id}",
"${a_resource.three.id}"
]
}
Then this will fail as it's unable to compute the count... unless the items in list_of_things
already exist, when it works. This means you can extend scripts that plan and run successfully but if you then destroy the resources and start from scratch they don't work.
resource "another_resource" "thing" {
count = "${length(local.list_of_things)}"
}
Workaround : replace count with a literal count or local
or var
variable with a literal value.