Architecture

Migrating a monolith to serverless with the strangler fig pattern

How to move from a monolith on EC2, Elastic Beanstalk, or containers to AWS serverless incrementally: routing, slicing, data strategies, and rollback.

  • 4 min read
  • Updated December 2, 2026

Rewriting a working monolith from scratch is one of the riskiest projects a team can take on: months without new features, a big-bang cutover, and a long tail of behavior nobody documented. The strangler fig pattern avoids that. You grow the new system around the old one, move functionality slice by slice, and remove the old code only when it no longer serves any traffic. This guide shows how to apply it when the target is AWS serverless.

The pattern in one picture

Clients ──► Routing layer ──┬──► New serverless components (growing)
                            └──► Existing monolith (shrinking)

Everything hinges on the routing layer: a single entry point that decides, per request or per event, whether the old or the new implementation handles it. Initially everything goes to the monolith. Over time, more routes point to new components, until the monolith handles nothing and can be switched off.

Step 1: assess before you move anything

Not every part of a monolith should become Lambda functions. Inventory the system and score each component:

  • Serverless fit: event-driven, short-running, spiky? Or long-running and steady (better on containers)?
  • Coupling: how much shared state and how many internal calls does it have?
  • Business value: does moving it reduce cost, risk, or delivery time?
  • Risk: how critical is it, and how well is it tested?

Good first candidates are leaf functionality with clear boundaries and low risk: a reporting endpoint, an image-processing job, a notification sender, a cron job running on a dedicated VM. They teach the team the new stack without betting the business on it.

Step 2: put a routing layer in front

Choose where traffic splits:

  • HTTP: Amazon API Gateway, CloudFront, or an Application Load Balancer can route by path to either the monolith or new Lambda-backed endpoints. API Gateway HTTP integrations can proxy unmigrated routes to the monolith's existing endpoint. CloudFront behaviors can route by path pattern to different origins.
  • Background jobs: replace a cron entry on the server with an EventBridge Scheduler schedule that triggers the new implementation, and disable the old job.
  • Events: have the monolith publish domain events (for example, OrderPlaced) to EventBridge. New consumers can react to them without the monolith knowing who listens.

The routing layer must make switching reversible: moving a route back to the monolith should be a configuration change, not a deployment of new code.

Step 3: migrate one slice at a time

For each slice:

  1. Build the new implementation in AWS CDK and TypeScript, with tests and observability.
  2. Shadow or compare where possible: run the new path alongside the old one and compare results, or start with a small share of traffic.
  3. Switch the route, watching error rates and latency.
  4. Hold the old path available until the new one is proven over a full business cycle.
  5. Remove the old code and infrastructure.

Weighted routing (for example, Lambda aliases with traffic shifting, or gradual deployments through CodeDeploy) helps for risky slices.

Step 4: decide how to handle data

Data is where migrations stall. Choose a strategy per slice:

  • Shared database, temporarily. The new component reads and writes the monolith's database directly. Fastest to start, but it couples the two; treat it as a stepping stone. Lambda works well with Aurora and RDS through RDS Proxy, which pools connections.
  • Monolith owns, new component asks. The new code calls an API in the monolith for the data it needs. Clean boundaries, more latency.
  • Change data capture. Replicate changes from the relational database into the new store (for example, DynamoDB) with AWS DMS or database events, so the new component has its own copy.
  • New service owns the data. Migrate the data once, make the new component the source of truth, and have the monolith call it. This is the end state you want for most bounded contexts.

When the target is DynamoDB, model from access patterns rather than copying tables one-to-one — see DynamoDB single-table design.

Step 5: handle cross-cutting concerns early

Some things need to work across old and new from the first slice:

  • Authentication: both sides must accept the same tokens. Moving identity to Amazon Cognito or validating your existing IdP's JWTs in API Gateway authorizers keeps users signed in across the boundary.
  • Observability: propagate a correlation id through the routing layer, the monolith, and new components so a request can be traced end to end.
  • Configuration and secrets: move them to SSM Parameter Store or Secrets Manager so both sides read the same values.

Common mistakes

  • Migrating the hardest part first. Start where learning is high and risk is low.
  • Distributed monolith. Splitting into many functions that all call each other synchronously recreates the monolith with network latency. Use events and queues between bounded contexts.
  • Never finishing. Slices that are "almost done" leave two implementations to maintain. Plan the removal step and do it.
  • Lift-and-shift into Lambda. Wrapping a whole framework app in one function can be a useful first step, but on its own it rarely delivers the benefits you migrated for.

How long does it take?

It depends on size and coupling, but the shape is predictable: the first slice takes longest because it establishes the routing layer, pipeline, and conventions; later slices get faster. Business value arrives with every slice, not at the end.

Summary

Put a reversible routing layer in front of the monolith, move low-risk slices first, choose a data strategy per slice, and remove old code as you go. The system keeps working — and keeps shipping features — throughout the migration.

Our migration to serverless service runs this process with an assessment, a wave plan, and reviewed Change Plans for every switch.

Services

Related services

How we can help you put this guide into practice.

Guides

More guides

Keep reading.

Let's make your serverless workload simpler, safer, and cheaper.

Start with a free 30-minute intro call with a serverless engineer.

Book a consultation