This project demonstrates how to setup a AWS stack with aws-cdk
.
Inspect the code at infra
to see how the various components are defined.
Notice we are also able to pass environement variables to the lambda function.
├── infra
│ ├── bin/index.ts <- Entry point to your stack definitions
│ ├── services <- Service definitions
│ ├── stacks <- Stack definitions
│ └── utils
├── src <- Application code
├── cdk.json <- Entry point for aws-cdk cli
├── package.json
└── README.md
You need to install aws-cdk globally:
npm i -g aws-cdk
It would be easy to integrate this build and deploy process on any CI pipeline.
- Install the application code:
npm i
oryarn
- Install the infra code
cd infra
andnpm i
- Finally run build & deploy:
npm run deploy
oryarn deploy
Once deployed you should now have:
- A DynamoDB table called
jobs
- 3 Lambda functions (2 With Rest API Integration)
- A Rest API Gateway with 2 methods (GET | POST) on
/jobs
resource - A state machine with conditional steps
- You can invoke the state machine manually via AWS console to see the step functions in action.
- Or you can invoke a lambda function that triggers the step function tasks via API Gateway
POST /jobs
.