Base template to deploy your next destination function with
- Click
Use This Templateabove (If Segment PS, add toSegment Services EngineeringOrganization
nvm use(to get the right version of NodeJS)npm install(to install npm dependencies)
npm run test
- The Buildkite pipeline also runs tests before deploying
- Tests are created in
src/index.test.js
The pipeline is defined in .buildkite/pipeline.yml. It
installs dependencies, runs tests, then deploys the function to the target
environment via scripts/deployDestinationFunction.js.
- Create a Buildkite pipeline pointed at this repo (GitHub webhook + a queue with
connected agents). On the
twilio-primary-defaultcluster, use a live general-purpose queue such asgeneral-001— thedefaultqueue is paused and has no agents, so jobs sent there hang in "queuing". - Create the Function in your Segment Workspace.
- Create a Public API Token to allow for deploying.
- Store the deploy secrets in AWS Secrets Manager as a single JSON secret and
let the pipeline read them at deploy time by assuming an IAM role via the
Buildkite OIDC provider (no static keys, no Buildkite-stored secrets):
- Secret
segment/destination-function-template(regionus-west-2, account058449100246) with shape:{ "FUNCTION_ID": "dfn_...", "PUBLIC_API_TOKEN": "..." } - IAM role
twilio-internal_destination-function-templateis assumed by theaws-assume-role-with-web-identityplugin; its trust policy is scoped to this pipeline's slug and it may only read this one secret. - The deploy step sources
.buildkite/fetch-secrets.shto load them. See the internal "Assuming IAM Roles" guide to reproduce this for a new function repo (new secret + new role scoped to the new slug).
- Secret
The pipeline deploys feature branches to DEV automatically. To promote to QA/PROD:
- Uncomment the QA/PROD
blockand deploy steps in.buildkite/pipeline.yml. - Push your changes.
- On a
mainbuild, unblock theRelease to QA(thenRelease to PROD) step in the Buildkite UI to promote the deploy. The target environment is selected via theDEPLOY_ENVvariable on each step.
