Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I inject external service VCAP_SERVICES into my app?

If I have a MessageHub service in one space, MY_ANALYTICS_SPACE, and I have an application in another space MY_WEBAPPS_SPACE. These spaces represent two different parts of the organisation and have been designed to be kept separate.

However, enterprise wide integration technologies like MessageHub are likely to span multiple spaces.

Is it possible to inject the connection details for MessageHub into the VCAP_SERVICES for my application when the service and application are in different spaces?

like image 289
Chris Snow Avatar asked Jan 25 '26 05:01

Chris Snow


1 Answers

thanks for your question.

Yes this capability is offered by the user-provided services function.

Here's some example shell script invocations that would achieve this:

cf target -s MY_ANALYTICS_SPACE
cf create-service messagehub standard common-messagehub
cf create-service-key common-messagehub Credentials-1
JSON=$(cf service-key common-messagehub Credentials-1 | tail -n +3)
cf target -s MY_WEBAPPS_SPACE
cf create-user-provided-service common-messagehub -p "${JSON}" \
    || cf update-user-provided-service common-messagehub -p "${JSON}"
like image 131
Dominic Evans Avatar answered Jan 26 '26 23:01

Dominic Evans