it
CDK Construct Event Driven Design — สร้าง

CDK Event Driven

AWS CDK Construct Event Driven Architecture EventBridge SQS Lambda Step Functions Serverless TypeScript Python Production
| Pattern | AWS Services | Use Case | CDK Construct Level |
|---|---|---|---|
| Fan-out | EventBridge → Lambda × N | Notify multiple services | L3 (Pattern) |
| Queue Processing | SQS → Lambda | Async job processing | L2 (SqsEventSource) |
| Saga | Step Functions | Distributed transactions | L3 (Custom) |
| CQRS | API GW + DynamoDB Stream | Separate read/write | L3 (Custom) |
| Event Sourcing | Kinesis + DynamoDB | Audit trail, replay | L3 (Custom) |
| DLQ | SQS DLQ + Lambda | Failed event handling | L2 (deadLetterQueue) |

เคล็ดลับ
- L2: ใช้ L2 Construct เป็นหลัก Default ดี Grant Permission ง่าย
- DLQ: ทุก Queue ต้องมี DLQ ไม่มีข้อยกเว้น ป้องกัน Event หาย
- EventBridge: ใช้ EventBridge เป็น Central Event Router ไม่ใช่ SNS
- Test: เขียน CDK Assertion Test + cdk-nag ทุก Stack
- Reuse: สร้าง L3 Construct สำหรับ Pattern ที่ใช้ซ้ำ Publish npm
AWS CDK คืออะไร
IaC Framework TypeScript Python Java Construct L1 L2 L3 CloudFormation AWS Service CDK CLI Deploy synth diff Reusable npm





