What is AWS CDK?
AWS CDK is an interesting project which allows you to provision and deploy AWS infrastructure with code. Currently TypeScript, JavaScript, Python, Java, C#/.Net are supported. You can compare AWS CDK with following technologies:- AWS CloudFormation
- AWS SAM
- Serverless Framework
Project Setup
Install cdk with:npm install -g aws-cdk
Create a directory for your project. Inside the directory init cdk:
Counter Function Code
Create a directory for your API functionmkdir api
Inside the API folder, init and npm project and install ioredis.
Counter Service
Go back to the top directory, install lambda and api-gateway libraries:Update the Stack
Updatelib/api-with-cdk-stack.ts
: