> Markdown version of [/videos/812-building-reliable-serverless-applications-with-aws-cdk-and-testing?t=30](https://www.wearedevelopers.com/videos/812-building-reliable-serverless-applications-with-aws-cdk-and-testing?t=30). Every page supports `.md` or `Accept: text/markdown`. Links point to the HTML versions so they work for humans too. Agent guide: [/agents.md](https://www.wearedevelopers.com/agents.md). --- # Building Reliable Serverless Applications with AWS CDK and Testing Moving to AWS serverless eliminates ops overhead, but how do you test what you cannot run locally? Master AWS CDK by pairing local mocks with real-cloud integration tests. - **Speakers:** [Raphael Manke](https://www.wearedevelopers.com/@raphael-manke) - **Event:** World Congress 2023 - **Published:** November 10, 2023 - **Duration:** 25:18 - **URL:** https://www.wearedevelopers.com/videos/812-building-reliable-serverless-applications-with-aws-cdk-and-testing ## Summary Transitioning from container-based, heavy-operation architectures to serverless environments in AWS solves core challenges around scalability, operational complexity, and security patching. By replacing self-managed Docker clusters with a fully managed serverless stack—including API Gateway, AWS Lambda, DynamoDB, EventBridge Pipes, and Amazon SQS—engineering teams drastically reduce infrastructure overhead. However, this shift introduces immediate friction around testing: without complete local control of the infrastructure, developers must rethink how to validate complex, event-driven cloud environments and maintain high testing coverage. To model this architecture efficiently, developers utilize the AWS Cloud Development Kit (AWS CDK), defining stacks and nested constructs using typed languages like TypeScript rather than writing raw CloudFormation templates. Validating this infrastructure setup requires a multi-layered testing strategy. For runtime execution within Lambda functions, standard TypeScript testing environments and mocked API responses suffice, occasionally supplemented by local Java-based DynamoDB containers to provide rapid feedback for integration tests. At the infrastructure level, fine-grained template assertions and snapshot testing allow developers to evaluate synthesized CloudFormation outputs, verifying that resources and routes are correctly generated without triggering manual cloud deployments. Additionally, spying on internal CDK operations ensures that vital permissions, such as granting a Lambda function read and write policies for a database table, are strictly enforced during synthesis. Testing fully managed event structures, such as EventBridge Pipes transitioning database records directly to an SQS queue, presents a unique challenge because no local emulators exist for these integrations. To overcome this limitation, the CDK integration test runner proves essential. This tool dynamically deploys the isolated stack directly to the cloud, executes operations via temporary Step Functions to trigger and poll for expected outcomes within precise timing windows, and then safely destroys the runtime assets. Ultimately, mastering serverless engineering requires teams to aggressively pair rapid local mocks for business logic alongside ephemeral real-cloud deployments for strict integration validation. **Keywords:** aws cdk, serverless testing strategies, aws lambda integration, infrastructure as code validation, dynamodb local testing, eventbridge pipes architecture, cloudformation assertions, cdk construct spying, cdk integration test runner, api gateway routing, typescript serverless development, amazon sqs streaming, ephemeral testing environments ## Chapters 1. **Container migration and operational complexity challenges** (00:30) — How a fictional team running a complex containerized platform explores cloud solutions to reduce operational overhead. 1. **Migrating to serverless and addressing testability concerns** (02:58) — How skepticism around testing fully managed infrastructure leads to experimenting with migrating a real use case. 1. **Defining a serverless architecture using AWS CDK** (05:31) — How provisioning infrastructure as object-oriented code generates standardized templates for deployment consistency. 1. **Creating API gateways and lambda function constructs** (09:06) — How incoming requests are routed from public gateways to application logic for validation and storage. 1. **Local runtime tests and fine-grained template assertions** (11:18) — How mocking logic locally evaluates functionality while template assertions prevent unintended infrastructure drift. 1. **Integrating lambda functions with managed dynamodb tables** (13:15) — How configuring access policies and passing table references integrates standalone serverless functions with managed databases. 1. **Validating database interactions in local integration tests** (14:43) — How executing local integration tests against mocked database containers validates data interaction without cloud provisioning. 1. **Streaming database events to SQS via eventbridge pipes** (16:38) — How event pipes seamlessly transform managed streams into standard messaging payloads for queuing. 1. **Executing cloud deployments using integration test runner** (18:26) — How temporary resource deployment in live environments validates end-to-end integration of fully managed, untestable components. 1. **Structuring a comprehensive serverless application testing strategy** (20:33) — How separating local execution, template checks, and cloud verification unifies the strategy for serverless systems. 1. **Audience Q&A on SDK spying and dynamodb** (23:17) — How manipulating template synthesis configurations and localized endpoints facilitates complex infrastructure testing edge cases. ## Related Moments - [Audience Q&A on CDK implementation and automated testing](https://www.wearedevelopers.com/videos/740-the-power-of-cloud-development-kit-cdk-how-to-get-the-most-out-of-it) (from "The power of Cloud Development Kit (CDK): How to get the most out of it") - [Recapping serverless architectures and Swift cloud integrations](https://www.wearedevelopers.com/videos/133-server-side-serverless-in-swift) (from "Server Side Serverless in Swift") - [Real-world challenges in adopting serverless architectures](https://www.wearedevelopers.com/videos/56-end-the-monolith-lessons-learned-adopting-serverless) (from "End the Monolith! Lessons learned adopting Serverless") - [Transitioning from pure code functions to serverless containers](https://www.wearedevelopers.com/videos/1008-serverless-java-in-action-cloud-agnostic-design-patterns-and-tips) (from "Serverless Java in Action: Cloud Agnostic Design Patterns and Tips") - [Discussing history and enterprise adoption of serverless](https://www.wearedevelopers.com/videos/34-serverless-past-present-and-future) (from "Serverless: Past, Present and Future") - [Exploring distinct components within the serverless ecosystem](https://www.wearedevelopers.com/videos/34-serverless-past-present-and-future) (from "Serverless: Past, Present and Future") ## Related Articles - [MLops – Deploying, Maintaining And Evolving Machine Learning Models in Production](https://www.wearedevelopers.com/magazine/115-mlops-deploying-maintaining-and-evolving-machine-learning-models-in-production) - [Devs vs. Marketers, COBOL and Copilot, Make Live Coding Easy and more - The Best of LIVE 2025 - Part 3](https://www.wearedevelopers.com/magazine/663-devs-vs-marketers-cobol-and-copilot-make-live-coding-easy-and-more-the-best-of-live-2025-part-3) - [All the videos of Halfstack London 2024!](https://www.wearedevelopers.com/magazine/521-all-the-videos-of-halfstack-london-2024) - [Dev Digest 120 - Apple and peers](https://www.wearedevelopers.com/magazine/455-dev-digest-120-apple-and-peers) ## Related Jobs - [Software Engineer, Platform Engineering (L2)](https://www.wearedevelopers.com/jobs/ext/1956829-software-engineer-platform-engineering-l2) at **Twilio** - [Software Engineer L2 - Cloud Infrastructure](https://www.wearedevelopers.com/jobs/ext/1293339-software-engineer-l2-cloud-infrastructure) at **Twilio** - [Software Engineer L2 - Cloud Infrastructure](https://www.wearedevelopers.com/jobs/ext/1282024-software-engineer-l2-cloud-infrastructure) at **Twilio** - [Software Engineer L2 - Cloud Infrastructure](https://www.wearedevelopers.com/jobs/ext/1644423-software-engineer-l2-cloud-infrastructure) at **Twilio** - [Devops Engineer](https://www.wearedevelopers.com/jobs/ext/1940926-devops-engineer) at **Bitpanda** - [Lead Software Engineer - Data Engineering](https://www.wearedevelopers.com/jobs/ext/2000968-lead-software-engineer-data-engineering) at **Dynatrace**