Connecting Your Application to a Platform Service Instance
To establish communication between the service instance that you have created and your application, you bind your application to the service instance.
Before You Begin
Deploy your application to Cloud Foundry.
About This Task
When you bind your application to your service instance, Cloud Foundry provisions the service's connection details in the VCAP_SERVICES environment variable. Cloud Foundry runtime uses the VCAP_SERVICES environment variable to communicate with a deployed application about its environment.
You can retrieve the following instance details from VCAP_SERVICES environment variable:
- An
instance_uri
for your service instance. - A
instance_GUID
is thezoneID
for your service instance. - HTTP header information to access your service instance. It includes:
http-header-name
asPredix-Zone-Id
http-header-value
- An
oauth-scope
for your instance. The end-user token requires the scope to access the specific service instance.
If you bind to a UAA service instance, you get the following information in addition to instance_uri
and instance_GUID
:
-
A
uaa_instance_issuerId
for your instance. TheissuerID
is required when you create an instance of another service that uses your UAA instance for authentication.
Procedure
Example
If you bind an application, myApp, to a UAA instance, the following messages are returned:
Getting env variables for app myApp in org predix-platform / space security as [email protected]...
OK
...
],
"predix-uaa": [
{
"credentials":
{
"issuerId":
"https://ff27c315-d027-4d1d-a30c-64f49b369ed9.predix-uaa.run.aws-usw02-pr.ice.predix.io/oauth/token",
"uri":
"https://ff27c315-d027-4d1d-a30c-64f49b369ed9.predix-uaa.run.aws-usw02-pr.ice.predix.io",
"zone": {
"http-header-name": "X-Identity-Zone-Id",
"http-header-value": "ff27c315-d027-4d1d-a30c-64f49b369ed9"
}
},
"label":
"predix-uaa",
"name":
"my_uaa_instance",
"plan":
"free",
"tags":
[]
}
],
In this example, the following values are displayed:
uaa_instance_issuerId
=https://ff27c315-d027-4d1d-a30c-64f49b369ed9.predix-uaa.run.aws-usw02-pr.ice.predix.io/oauth/token
uaa_instance_uri
=https://ff27c315-d027-4d1d-a30c-64f49b369ed9.predix-uaa.run.aws-usw02-pr.ice.predix.io
uaa_instance_GUID
=ff27c315-d027-4d1d-a30c-64f49b369ed9
If you bind an application, myApp, to the ACS service instance, the following messages are returned:
Getting env variables for app myApp in org predix-platform / space security as [email protected]...
OK
...
],
"predix-acs": [
{
"credentials": {
"uri": "https://predix-acs.run.aws-usw02-pr.ice.predix.io",
"zone": {
"http-header-name": "Predix-Zone-Id",
"http-header-value": "9615a95a-9275-4a82-926d-89f06cbe04e1",
"oauth-scope": "predix-acs.zones.9615a95a-9275-4a82-926d-89f06cbe04e1.user"
}
},
"label": "predix-acs",
"name": "acs-sample-instance",
"plan": "Tiered",
"provider": null,
"syslog_drain_url": null,
"tags": []
}
],
In this example, the following values are displayed:
acs_instance_uri
=https://predix-acs.run.aws-usw02-pr.ice.predix.io
acs_instance_GUID
=9615a95a-9275-4a82-926d-89f06cbe04e1
http-header-name
=Predix-Zone-Id
http-header-value
=9615a95a-9275-4a82-926d-89f06cbe04e1
oauth-scope
=predix-acs.zones.9615a95a-9275-4a82-926d-89f06cbe04e1.user