-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Hi
I have a resource and a binding from a redis on this
resource "cloudfoundry_app" "my_resource" {
..
service_bindings = [
{
service_instance : cloudfoundry_service_instance.redis_instance.name
}
]
..
environment = {
redis_host = "any_host.com"
}
}
a
data "cloudfoundry_service_credential_binding" "redis_binding" {
service_instance = cloudfoundry_service_instance.redis_instance.id
app = cloudfoundry_app.my_resource.id
}
output "redishost" {
jsondecode(data.cloudfoundry_service_credential_binding.redis_binding.credential_bindings[0].credential_binding)["credentials"]["hostname"]
sensitive = true
}
which works fine and I see the redishost with
terraform output redishost
But if I am trying to use this value in the cloudfoundry_app
environment = {
redis_host = jsondecode(data.cloudfoundry_service_credential_binding.redis_binding.credential_bindings[0].credential_binding)["credentials"]["hostname"]
}
I get
│ Error: Cycle: data.cloudfoundry_service_credential_binding.redis_binding, cloudfoundry_app.my_resource
How can I inject the
jsondecode(data.cloudfoundry_service_credential_binding.redis_binding.credential_bindings[0].credential_binding)["credentials"]["hostname"]
to
environment.redis_host