I would like to access another Bluemix service from an OpenWhisk action, and prefer not to pass credentials from outside. It doesn't seem that VCAP_SERVICES is present in the environment of the JVM. Is there a way to retrieve it?
1 Answers
Indeed there is no VCAP_SERVICES
environment variable in OpenWhisk.
If you are using Cloudant services in Bluemix, you will notice OpenWhisk in Bluemix automatically creates package bindings for your Cloudant service instances as described in the OpenWhisk Catalog documentation.
In my OpenWhisk development, the strategy I've adopted is to create a package where I defined parameters. Then I create my actions in this package. All actions inherit the parameters defined in the package so this gives me a simple way to share the service credentials. If I only have one action or no package, I would pass the credentials as parameters to the action when I create it.
An example here https://github.com/IBM-Bluemix/openwhisk-visionapp where I initialize my action:
wsk action create -p cloudantUrl [URL] -p cloudantDbName openwhisk-vision -p watsonApiKey [123] vision-analysis analysis.js