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.
- Run the following command to set
TRAY_API_URL:
export TRAY_API_URL=https://api.tray.io
If you are deploying the connector in a different region, use the region specfifc URL.
- 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:
...
...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:
Connector is currently being built, this could take a few minutes. Please check the connector status again later.
Connector is currently being deployed, this could take a few minutes. Please check the connector status again later.
Connector Deployed Successfully! ๐ ๐ ๐
Connector Deploy Failed, please try again or contact support
If the build itself was rejected, for example because the project declares a CDK version below the minimum the platform builds against, the status is BuildFailed and the reason is printed after it:
Connector Build Failed, please try again or contact support
Error: The connector's package.json targets a CDK version this platform no longer supports (minimum 7.0.0).
- @trayio/cdk-dsl "^6.0.0" does not admit any version at or above 7.0.0, which is the oldest this platform still builds against; declare @trayio/cdk-dsl as "^7.0.0" or newer.
Upgrade the project with the current @trayio/cdk-cli (npm install -g @trayio/cdk-cli), or edit package.json by hand, then deploy again.
See Minimum CDK version for deployments below.
Minimum CDK version for deployments
The platform builds every deployed connector against the current @trayio/cdk-dsl and @trayio/cdk-runtime, whatever version the project was developed with. To stop code written against an old CDK from meeting a newer one for the first time in production, a deployment is rejected at build time when the package.json in the connector declares either package with a range that cannot resolve to v7.0.0 or higher.
"*"(whattray-cdk connector initwrites),"latest","^7.0.0",">=6.0.0"or no entry at all are accepted: they all resolve to v7.0.0 or higher."^6.0.0","<7","6.x", an unparseable range or a dist-tag other thanlatestare rejected, with theBuildFailedmessage shown above naming the package, the range found and the fix.
To fix a rejected deployment, update the two packages in package.json to the current release, "^8.0.0" (or "*"), delete node_modules and package-lock.json, run npm i, confirm npm run build and npm test pass on Node 26, and deploy again. The Migration Guide has the full steps.
3. Share connector with emails
You can also use the API to share connectors. To make a connector available to every Tray customer, see Publish a public connector.
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.