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 buildcompile typescript to jsnpm run watchwatch for changes and compilenpm run testperform the jest unit testsnpm run deployto deploy this stack to your default AWS account/region with hotswap optioncdk deploydeploy this stack to your default AWS account/regioncdk diffcompare deployed stack with current statecdk synthemits the synthesized CloudFormation template
