terraform-provider-cloudfoundry
terraform-provider-cloudfoundry copied to clipboard
Add ability to manage bindings
Currently we can specify an application -> service binding when creating an app, but there is no explicit application binding resource; it's implicit.
However this means Terraform has no ability to manage bindings between apps and service instances if either one is managed outside of Terraform (or via another Terraform run).
I propose the creation of a new resource cloud_foundry_app_binding
which does exactly the same thing as running bind-service
, including the ability to specify bind-time parameters.
Hi @mogul, If I understand correctly, you could potentially simplify the process by using a data block to read the ID of the service instance and binding it to the application. This might make things easier for you.
In the case of managed app, and unmanaged service:
resource "cloudfoundry_app" "main" {
...
service_binding {
service_instance = data.cloudfoundry_service_instance.svc.id
}
...
}
data "cloudfoundry_service_instance" "svc" {
name_or_id = "unmanaged-postgres"
space = ...
}
In the case of unmanaged app and managed service instance. Clarification: cloudfoundry_service_binding
does not exist in this repository yet, which is what the enhancement is asking for. cloudfoundry_service_binding
only exists in my current fork of this repository at the moment.
data "cloudfoundry_app" "others" {
name_or_id = "unmanaged-app"
space = ...
}
resource "cloudfoundry_service_instance" "svc" {
...
}
resource "cloudfoundry_service_binding" "binding" {
application = data.cloudfoundry_app.others.id
service_instance = cloudfoundry_service_instance.svc.id
}
Yes, it's exactly that latter case I'm trying to resolve right now. And I prefer your resource name (cloudfoundry_service_binding
)!