Deploying a CDK connector using CLI


Overview

You can deploy connectors built through CDK using the CDK CLI.

Prerequisites - API token

In order to deploy a connector, you will need an RBAC (Role Based Access Control) API token, you can follow this guide on how to create one.

Deploying to different regions

Tray operates in 3 regions: US, EU and APAC. You will need to use the region specific base URL and RBAC token, for each region you wish to use the connector in.

Deployment flow

1. Deploy the connector

To deploy the connector, you will need to set two environment variables.

  1. Run the following command to set TRAY_API_URL :

export TRAY_API_URL=https://api.tray.io

warning

The above URL (https://api.tray.io) is for the US region.

If you are deploying the connector in a different region, use the region specfifc URL.

  1. Run the following command to set TRAY_API_TOKEN :

export TRAY_API_TOKEN=<API_TOKEN>

where API_TOKEN is the token you created as a pre-requisite for this step.

With the environment variables set now, you are ready to run the deploy command:

tray-cdk deployment create

The command will execute the tests and then deploy the connector. You should see a response similar to the one shown here:

Copy
Copied
...
...Test execution logs
...

Ran all test suites.
Tests ran successfully
Connector Build Started
Generating schemas for operation <operation_2_name>
Generating schemas for operation <operation_2_name>
Connector Build Finished
Connector Deploy Started
Connector Deploy Request Sent
Deployment [856b5518-6829-519f-9358-d34b7f848f07] is in progress

The connector should be available within the Tray app in a couple of minutes.

The deployment UUID: 856b5518-6829-519f-9358-d34b7f848f07 can be used to check the status as shown in the next step.

2. Check deployment status

You can check the status of the deployment using:

tray-cdk deployment get [CONNECTOR_NAME] [CONNECTOR_VERSION] [UUID]

where UUID is the unique deployment ID you received in the step above and CONNECTOR_NAME and CONNECTOR_VERSION are the values of name and version keys in the connector.json file respectively.

For the deployment shown above, it will be:

tray-cdk deployment get {connector-name} {connector-version} 856b5518-6829-519f-9358-d34b7f848f07

Depending on depployment status: building, deploying, deployed, and failed, You should see a response as follows:

buildingdeployingdeployedfailed
Copy
Copied
Connector is currently being built, this could take a few minutes. Please check the connector status again later.
Copy
Copied
Connector is currently being deployed, this could take a few minutes. Please check the connector status again later.
Copy
Copied
Connector Deployed Successfully! 🎉 🎉 🎉
Copy
Copied
Connector Deploy Failed, please try again or contact support

3. Share connector with emails

warning

You can't share connectors across different Tray organizations.

You can also use the API to share connectors.

Since you used a RBAC token of an API user to deploy the connector, it is technically owned by the API user.

The connector must be shared with you / anyone else before you / them can see it on Tray UI.

To do this, simply execute:

tray-cdk permissions add [CONNECTOR_NAME] [CONNECTOR_VERSION] --email="[COMMA SEPARATED EMAILS]"

e.g.

tray-cdk permissions add my-connector 1.0 --email="john.doe@domain.com, jane.doe@domain.com"

In the example above, john.doe@domain.com, jane.doe@domain.com would be two users within the API user's Tray org.