terraform-provider-ibm
terraform-provider-ibm copied to clipboard
Poor documentation of `ibm_code_engine_binding`
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
New or Affected Resource(s) or Datasource(s)
- ibm_code_engine_binding
Description
I'm trying to use ibm_code_engine_binding
to automate binding e.g. a postgres database to my code engine instances.
The documentation for component
states:
-
component
: A reference to another component
Okay, so the database I want to bind to my code engine app, right?
-
name
: The name of the referenced component.
So the name of my database.
-
resource_type
: The type of the referenced resource
Alright, and what are the valid values for this? I've tried databases-for-postgresql
which does not work. In fact, this fails due to a regex validation error during apply(instead of during planning), and so does the same thing with underscores instead of dashes.
This also leaves one asking: where do I actually specify which code engine app this resource is supposed to be bound to? The documentation examples further confuses by providing the following example
resource "ibm_code_engine_binding" "code_engine_binding_instance" {
component {
name = "my-app-1"
resource_type = "app_v2"
}
prefix = "MY_COS"
project_id = "15314cc3-85b4-4338-903f-c28cdee6d005"
secret_name = "my-service-access"
}
I can only assume app_v2
refers to a code engine application, but of course this is not documented anywhere on this page, but I can confirm this by looking at other documentation.. but clearly this is meant to be a binding to a COS resource, but then where is any reference to said COS resource?
As I've had to do before, I figured I'd try creating the binding manually, then import it and then look at the output from terraform. Unfortunately, the documentation for that states
You can import the ibm_code_engine_binding resource by using binding_id. The id property can be formed from project_id, and binding_id in the following format [..]
But nowhere is it described where you can get a binding id, and I've not been able to find it anywhere, not on the code engine service binding page(in urls or otherwise) or on the database side.
I discovered that the ibm cloud cli can list bindings: ibmcloud ce binding list
. There is an ID in there, but following the documentation and constructing and id <project_id>/<binding_id>
using this ID returns an error during apply:
"Result": {
│ "errors": [
│ {
│ "code": "parameter_invalid",
│ "message": "Bad request - The parameter 'id' is invalid. reason: TOOLONG",
│ "target": {
│ "name": "id",
│ "reason": "TOOLONG",
│ "type": "parameter"
│ }
│ }
│ ],
│ "status_code": 400,
│ "trace": "codeengine-api-61f504f2d86142afbf8c0bd2817c5502"
│ },
Hi @saevarb Thanks you for bringing the lack of clarity in the docs to our attentions, we are opening a ticket to improve them based on your feedback.
As for your issue, creating a service binding is actually a 3 step process.
-
Create a code engine app/job
-
Create a service-access secret that references your other ibm cloud service (in your case a postgres instance). This secret will contain all connection information related to your service instance.
-
Create a binding with your Code Engine app/job (
resource_type: app_v2
orjob_v2
) and the service access secret. This binding will connect your app/job to the service-access secret, giving your app/job access to the credentials stored within, thus allowing a connection between your app/job and postgres instance.
@jaksart1 Thanks a lot for your quick response. That makes sense, but yes, would be super useful to have as part of the documentation.