This repository provides a template for building and deploying a Saleor App using AWS Lambda, AWS API Gateway, and AWS CDK for infrastructure management.
- AWS Infrastructure-as-Code using CDK v2
- Saleor App SDK integration for writing handlers for AWS Lambda
- Example of webhook handling with ORDER_CREATED event example
- TypeScript with strict type checking
[API Gateway] (HTTP API)
│
├─ /api/manifest (GET) → [Manifest Lambda] (Node.js 22.x)
│ └─ Integrates with [Saleor App SDK]
│
├─ /api/register (POST) → [Register Lambda] (Node.js 22.x)
│ ├─ Handles Saleor app registration
│ └─ Uses [APL Storage] (File/Upstash)
│
└─ /api/webhook/order-created (POST) → [Webhook Lambda] (Node.js 22.x)
└─ Processes ORDER_CREATED events from Saleor
[Environment Variables]
├─ APL=upstash/file
├─ UPSTASH_URL
└─ UPSTASH_TOKEN
[Shared Resources]
├─ [AWS IAM] (Least-privilege roles)
├─ [CloudWatch Logs]
└─ [CDK Stack] (lib/saleor-app-aws-lambda-template-stack.ts)
-
HTTP API Gateway - Main entry point with three routes
-
Lambda Functions:
ManifestHandler
: Serves app manifest at/api/manifest
RegisterHandler
: Handles app registration at/api/register
OrderCreatedHandler
: Processes ORDER_CREATED webhooks
-
Environment Configuration:
APL=upstash # Storage backend (file/upstash) UPSTASH_URL= # Required for Upstash APL UPSTASH_TOKEN= # Required for Upstash APL
- Install dependencies:
pnpm install
- Configure environment:
cp .env.example .env
- Build project:
pnpm run build
- Deploy stack:
cdk deploy
The template includes an ORDER_CREATED
webhook handler that:
- Receives order creation events from Saleor
- Extracts order details using generated GraphQL types
- Returns 200 OK response with simple logging
// lambda/webhook/order-created.ts
export const handler = orderCreatedWebhook.createHandler((event, context, saleorContext) => {
console.log('Webhook received:', saleorContext.event);
return { statusCode: 200, body: 'OK' };
});
- Add new webhooks in
lambda/webhook/
directory - Modify GraphQL queries in
lambda/graphql/
- Extend CDK stack with additional AWS resources
- Implement custom business logic in handlers