Add Contrast service broker tile for Node.js
With a service broker, VMware Tanzu (formerly Pivotal Cloud Foundry) applications can easily bind to and consume services from the Apps Manager or the command line. The tile deploys the Contrast service broker for you as an application on VMware Tanzu. The broker works with applications in any language, including Node.js applications, and you can use it with one or more Contrast accounts.
When you add a tile, it creates one organization: the contrast-security-service-broker-org. Use this organization to deploy the Contrast service broker application. This requires 1 GB of memory.
Before you begin
Before you add the Contrast service broker tile, you must have:
VMware Tanzu Application Service 6.0 or later, with Tanzu Operations Manager and Apps Manager. The tile uses the Ubuntu Jammy stemcell and the cflinuxfs4 stack.
An active Contrast account.
The Cloud Foundry Node.js buildpack, version 1.6.52 or later, for any application using Contrast. The buildpack includes the Contrast hook. If you have a custom buildpack, you must copy the Contrast hook into it.
Steps
To add the Contrast service broker tile for Node.js:
Download the Contrast service broker tile from the VMware Tanzu Network.
Select Import a Product and then select the
contrast-security-service-broker-#.#.#.pivotaltile you downloaded.Note
If the file you downloaded has a ZIP extension rename it to
contrast-security-service-broker-#.#.#.pivotal.To add a service plan select Service Plans in the Contrast service broker tile and select Add.
You must add at least one before you can deploy the Contrast service broker tile. The tile requires some configuration before you can deploy it. The service broker does not include service plans by default.
Complete these configuration parameters in the service plan:
Contrast Url: The URL of your Contrast instance. Leave off
/Contrast/api. The default ishttps://app.contrastsecurity.com.Username: A Contrast user with application onboarding permission.
Organization UUID: The organization to onboard applications in.
Api Key: The API key.
Service Key: The service key.
Plan Name: The name of the plan as it appears in Apps Manager.
Proxy Host, Proxy Port: Optional. The proxy server the broker uses to reach Contrast.
Proxy Username, Proxy Password: Optional. The credentials, if your proxy server requires authentication.
See Find the agent keys for details on identifying the Organization UUID, Api Key, and Service Key.
After you define the service plan, select Save. If you want some applications to belong to different organizations, define the other plans you will need.
Select Apply Changes in the dashboard. This may take some time to finish.
Use the Cloud Foundry CLI to bind your application.
Open the project directory of the Node.js application you want to monitor.
Update the application's
package.jsonto add the Contrast Node agent as a dependency. For example:"@contrast/agent": "^5".Update the start script in
package.jsonto instrument with the agent. For example:"start": "node --import @contrast/agent app.js".Push the application to VMware Tanzu. For example, from your application’s directory, run the following command:
cf push myAppNodeBroker -t 180
Run the following:
cf service-access
Example output:
Getting service access as admin... broker: contrast-security-service-broker service plan access orgs contrast-security apptwo all
Run the following:
cf create-service contrast-security apptwo contrast
Example output:
Creating service instance contrast in org system / space apps as admin... OK
Run the following:
cf services
Example output (notice there are currently no bound apps):
Getting services in org system / space apps as admin... name service plan bound apps last operation broker upgrade available contrast contrast-security apptwo create succeeded contrast-security-service-broker
Run the following to bind the sample app to the service:
cf bind-service myAppNodeBroker contrast
Example output:
Binding service contrast to app myAppNodeBroker in org system / space apps as admin... OK
Run the following again to confirm the app is now bound to the service:
cf services
Example output:
Getting services in org system / space apps as admin... name service plan bound apps last operation broker upgrade available contrast contrast-security apptwo myAppNodeBroker create succeeded contrast-security-service-broker
Run the following command to restage the application now that it is bound to the service:
cf restage myAppNodeBroker
Go to Contrast to view the application.