Deployments and the tenant pipeline
With silo tenants, deploying a new version means updating the pooled stack and one stack per Platinum tenant, and that number grows with every sale. The tenant pipeline updates every stack listed in the tenant mapping table.
Code versions
Section titled “Code versions”scripts/upload-source.sh zips server/ and uploads it as source.zip to the versioned bucket serverless-saas-source-<account>-<region>. The S3 version id of each upload is the code version, and every consumer uses it:
- The provisioning job deploys new Platinum stacks from the newest version.
- The pipeline deploys a specific version to every tenant stack.
- Each stack records the version it runs in the mapping table as
codeCommitId, and/whoamireturns it ascodeVersion.
The pipeline
Section titled “The pipeline”Each box in a wave is a CodeBuild run of server/scripts/update-tenant.sh: it downloads that exact source.zip version, runs npm ci, then CDK_PARAM_TENANT_ID=<tenant> CDK_PARAM_COMMIT_ID=<version> cdk deploy <stackName> --exclusively. Waves run one at a time, and up to 5 stacks of a wave run in parallel.
Each mapping row has a waveNumber: 1 by default, or CDK_PARAM_WAVE_NUMBER when the stack is created. Put a few low-risk tenants in wave 1, watch their alarms, and let the rest follow. If any stack in a wave fails, later waves never start.
To move a tenant to wave 2:
aws dynamodb update-item --table-name <TenantMappingTable> --key '{"tenantId":{"S":"<tenant id>"}}' \ --update-expression 'set waveNumber = :w' --expression-attribute-values '{":w":{"S":"2"}}'What deploys what
Section titled “What deploys what”| Change | How to ship it |
|---|---|
| Tenant template code (services, authorizer, layer) | ./scripts/upload-source.sh, then the pipeline updates every tenant stack |
| Control plane, bootstrap or pipeline stack | ./scripts/deploy.sh you@example.com |
| Web apps or these docs | ./scripts/deploy-client.sh (add DOMAIN_NAME=… for the custom domain) |
deploy.sh deploys the stacks from your machine and then uploads the source, so the pipeline also runs once and stamps a versioned codeVersion on every tenant stack.