Skip to main content

Add the 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. You can deploy the Contrast service broker as a Node.js application on VMware Tanzu, and use one or more Contrast accounts. The broker exposes the Contrast service on the VMware Tanzu marketplace so you can create a service instance.

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 512MB of memory.

Before you begin

Before you add the Contrast service broker tile, you must have:

  • Pivotal Apps Manager and Ops Manager

  • An active Contrast account

  • The default Node.js buildpack for any application using Contrast. If you have a custom buildpack, you must copy the Contrast framework support and configuration into it.

Steps

To add the Contrast service broker tile for Node.js:

  1. Download the Contrast service broker tile from the VMware Tanzu Network.

  2. Select Import a Product and then select the contrast-security-service-broker-#.#.#.pivotal tile you downloaded.

    Note

    If the file you downloaded has a ZIP extension rename it to contrast-security-service-broker-#.#.#.pivotal.

  3. To add a service plan select Service Plans in the Contrast service broker tile and select Add. The tile requires some configuration before you can deploy it. The service broker does not include service plans by default. You must add at least one before you can deploy the Contrast service broker tile.

  4. Complete these configuration parameters in the service plan:

    • TeamServer: The URL for your Contrast application instance

    • TeamServer Service Key: Organization service key

    • TeamServer API Key: Organization API key

    • Organization UUID: Organization ID to which the application will belong

    • Username: Your Contrast username

    • Plan Name: Name of the plan as it will appear in Apps Manager

    • Proxy Host: The hostname of a proxy for the service broker to communicate with Contrast

    • Proxy Port: The proxy port

    • Proxy Username: The proxy username if it requires authentication

    • Plan Password: The proxy password

  5. 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.

  6. Select Apply Changes in the dashboard. This may take some time to finish.

  7. Now, use the Cloud Foundry CLI to bind your application.

  8. Clone the project to a local directory. For example: Node/pcf/node-hello-world.

  9. Update the applications package.json to add the Contrast Node agent as a dependency. For example: "@contrast/agent": "^5".

  10. Update the start script in package.json to instrument with the agent. For example: "start": "node --import @contrast/agent app.js".

  11. Push the application to VMwareTanzu. For example, from the Node/pcf directory, run:

    cf push myAppNodeBroker -p node-hello-world \
        -b 'https://github.com/cloudfoundry/nodejs-buildpack.git'   \
        -t 180
  12. Then 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   
  13. Then run the following:

    cf create-service contrast-security apptwo contrast

    Example output:

    Creating service instance contrast in org system / space apps as admin...
    OK
  14. Then 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   
  15. 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
  16. 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   
  17. Run the following command to restage the application now that it is bound to the service:

    cf restage myAppNodeBroker
  18. Go to Contrast to view the application.

See also

Add Contrast service broker