Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to manage bindings #477

Open
mogul opened this issue Apr 5, 2023 · 2 comments
Open

Add ability to manage bindings #477

mogul opened this issue Apr 5, 2023 · 2 comments

Comments

@mogul
Copy link
Contributor

mogul commented Apr 5, 2023

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.

@sleungcy
Copy link
Collaborator

sleungcy commented Apr 6, 2023

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
}

@mogul
Copy link
Contributor Author

mogul commented Apr 6, 2023

Yes, it's exactly that latter case I'm trying to resolve right now. And I prefer your resource name (cloudfoundry_service_binding)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants