Chris Snow
Chris Snow

Reputation: 24636

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?

Upvotes: 3

Views: 168

Answers (1)

Dominic Evans
Dominic Evans

Reputation: 370

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}"

Upvotes: 5

Related Questions