This project is an example implementation of multi-tenant API build with AWS CDK and Typescript created for blog post Building multi-tenant internal services in AWS and CDK: Part 1 — API Gateway and App Sync.
Prerequisites:
- Typescript
- AWS CLI
- AWS CDK CLI
If not configured add your AWS Account to environment variable CDK_DEFAULT_ACCOUNT
and region to CDK_DEFAULT_REGION
.
Build and deploy app with:
npm run build && npm run deploy
Run script that signs requests with your local AWS credentials and sends test API request.
npx ts-node scripts/invoke-api.ts
Right now the app deploys API Gateway with two clients that also use your AWS accounts. You can update list of API clients and use different AWS accounts in multi-tenant-api-example-stack.ts.
The cdk.json
file tells the CDK Toolkit how to execute your app.
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testsnpm run deploy
to deploy this stack to your default AWS account/region with hotswap optioncdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template