This is a CDK project to create AWS IaC for a fake Transaction project.
- Transaction service receives either
deposit
orwithdrawal
events via httpPOST
to API gateway AWS Lambda producer function - These events are sent to AWS EventBridge where they are then re-routed based on EventBridge rules to specific consumer lambda functions
- If these Lambda functions are successful then they just log a success message
- If these Lambda functions fail, then the event is sent to a deadLetterQueue to be re-tried
Consists of:
- Default region VPC
- Two Lambda REST API Gateway endpoints
- POST /transaction/deposit
- POST /transaction/withdrawal
- An API Gateway triggered Lambda function that puts events in EventBridge
- Four consumer Lambda functions that consume events from EventBridge based on different rules
- A dead letter queue for each of the consumer Lambda functions for events that fail
- Ensure you have a
.env
file if you want to dpeloy from local (see.env.example
) - Make sure you have
.aws/credentials
file. This is what it looks like:[default] aws_access_key_id=xxxXXXXXXXxxxXXxxxx aws_secret_access_key=xxxXXXXXXXxxxXXxxxx
- And a
.aws/config
file:[default] region=us-west-2 output=json
- You can run the test suite (inside
./test/
) included with the stack with
npm test
- To view/generate the CloudFormation template
cdk synth --profile default
- To deploy the stack
cdk deploy --profile default
- Deployment pipeline via Github Actions (see
.github/workflows/deploy.yml
) - To deploy to stage
dev
, merge/push todev
branch - To deploy to stage
prod
, merge/push toprod
branch
- to destroy the stack and remove all created resources simply run
cdk destroy --profile default
// POST https://liz92p0to8.execute-api.us-west-2.amazonaws.com/prod/transaction/deposit
// HEADER x-api-key xxxxxXXXxXXxXXXXXxxx
{
"location": "US",
"amount": 45,
"cardNumber": 45566541332646,
"bankId": 4052
}