Welcome to your Serverless Websocket Chat sample CDK TypeScript project
January 3, 2023 · View on GitHub
The cdk.json file tells the CDK Toolkit how to execute your app.
Project structure
├── infrastructure-ts # Infrastructure code via CDK(Typescript).
│ ├── bin # CDK App - Deploys the stacks
│ ├── lib #
| | ├── auth-stack.ts # Contains the Cognito Userpool
| | ├── database-stack.ts # DynamoDB table definitions
| | ├── frontend-stack.ts # Cloudfront distribution, S3 bucket for static hosting and additional resources
| | ├── rest-api-stack.ts # ApiGateway REST API to support the frontend application
| | ├── websocket-stack.ts # ApiGateway Websocket API for real-time communication
| | ├── observability-stack.ts # CloudWatch Dashboard with custom metrics
├── UI # Angular 12 Single Page Application (SPA)
└── ...
Deployment
- Restore NPM packages for the project
npm install
- Bootstrap your AWS account as it's required for the automated Docker image build and deployment
cdk bootstrap aws://{ACCOUNT_ID}/{REGION}
- Synthesize the cdk stack to emits the synthesized CloudFormation template. Set up will make sure to build and package the lambda functions residing in the handlers directory.
cdk synth
- Deploy the CDK application
cdk deploy --all
Useful commands
npm run buildcompile typescript to jsnpm run watchwatch for changes and compilenpm run testperform the jest unit testscdk deploydeploy this stack to your default AWS account/regioncdk diffcompare deployed stack with current statecdk synthemits the synthesized CloudFormation template