AWS CDK Stripe Webhook Lambda is a NodeJS and TypeScript based application designed to generate a Lambda function deployable via AWS CDK. This Lambda function is specifically tailored for handling Stripe webhooks with enhanced security through webhook signature verification.
- NodeJS and TypeScript Integration: Built using NodeJS and TypeScript within the AWS Cloud Development Kit (CDK) for a robust and type-safe development experience.
- Stripe Webhook Handling: Configured to process Stripe webhook events, with a primary focus on validating webhook signatures for security.
- AWS Lambda Function: Utilizes AWS Lambda, leveraging Node 18, to provide a scalable and efficient serverless backend.
- AWS Secrets Manager Integration: Automatically retrieves necessary secrets (Stripe secret and webhook secret) stored in AWS Secrets Manager, ensuring secure and convenient access to sensitive data.
- Simplified Deployment: Streamlined deployment process using AWS CDK commands, abstracting away the complexity of AWS infrastructure management.
Before deploying this application, ensure that:
- Stripe Secrets in AWS Secrets Manager: A secret named
STRIPE_TEST_CREDENTIALS_WITH_WEBHOOK
is pre-stored in AWS Secrets Manager. This secret should be an object containing:STRIPE_SECRET_KEY
: Your Stripe test secret key.STRIPE_SECRET_WEBHOOK
: Stripe webhook secret obtained after configuring the Lambda function URL in the Stripe developer dashboard (You won't have this until after you deploy, but can update the value then.)
![image](https://private-user-images.githubusercontent.com/5106417/298399984-45a251a1-8213-4258-8849-90450ced2533.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI4NjcxMzksIm5iZiI6MTcyMjg2NjgzOSwicGF0aCI6Ii81MTA2NDE3LzI5ODM5OTk4NC00NWEyNTFhMS04MjEzLTQyNTgtODg0OS05MDQ1MGNlZDI1MzMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgwNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MDVUMTQwNzE5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Y2U3YzYwYzJmNzZkZGIwYzU3YzhjZjVkYmRiNjhkZDNhZjc5OGM1MGU4MDNmOWI5ZmZiZTM0ZTM4YjY3MGEzMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.KA1FqCGlxhGg478ngtD8FA0TQmPlCn6fOgEROhV9LC0)
- Clone the Repository:
git clone https://github.com/focusOtter/stripe-webhook-example.git
- Install Dependencies:
Navigate to the cloned directory and run:
npm install
- Synthesize CloudFormation Template:
Ensure there are no errors in the CloudFormation template generation:
npx aws-cdk synth
- Deploy to AWS:
Deploy your application to AWS:
npx aws-cdk deploy
Once deployed, the Lambda function will log event data to AWS CloudWatch, particularly focusing on checkout.session.completed
events, allowing you to monitor and debug the Stripe webhook interactions.
This project is released under the MIT License.
Note: This README assumes a basic understanding of AWS services, including Lambda, AWS CDK, and AWS Secrets Manager, along with familiarity with Stripe's webhook system. It is essential to ensure all AWS and Stripe configurations comply with your project's requirements and security guidelines.