I am trying to pass a variable of type list as follow:
In the cf-app.tf
file:
resource "cloudfoundry_app" "my-app" {
service_binding = "${var.service-bindings}"
}
In variables.tf
file:
variable "service-bindings" {
type = "list"
default = []
}
In deployment.tf
file:
module "nested-module" {
source = "../my-app"
service-bindings = [
{
service_instance = "dummy1"
},
{
service_instance = "dummy2"
}
]
}
but I m getting the below error, this is a known terraform 11
issue and has been fixed in terraform 12
:
Error: module.nested-module.cloudfoundry_app.myapp: service_binding: should be a list
I followed this issue but my challenge is with the string of elements...
I am currently using terraform version 11
.
Can someone help me resolve this in a hacky way?
Thank you in advance!
Why do you have:
When
var.service-bindings
is a list and theservice_binding
input expects a list? Shouldn't this be:I don't have Terraform v0.11 installed and I have no intention of installing it to test this, but you could try:
Removing
type = "list"
from your variable. Will it still throw this error if you don't ask it to validate that the type is correct?Does 0.11 support the
jsonencode
function? If so, try: