This repository contains an AWS SAM iterative replacement template. Iterative replacement allows you to migrate a monolith one route at a time by placing an Amazon API Gateway HTTP API in front of your existing application. Once all traffic is proxied through your HTTP API, you rewrite routes one at a time to serverless components. This enables you to modernize your monolith while reducing risk.
This template takes a single parameter, PassthroughTarget
, of the form https://api.anycompany.com. Note that there is no trailing forward slash at the end of the target.
This template produces a single output, APIRoot
, which is the root URL of your new HTTP API.
This template also includes two routes and an Amazon DynamoDB table to get you started:
- POST /customer to create a new record
- GET /customer/{id} to retrieve a record
These routes are integrated with two separate AWS Lambda functions, customer-read and customer-write. These functions execute with AWS SAM policy templates that appropriately restrict their access to the DynamoDB table.
- Install the AWS SAM CLI
- From a terminal, run
sam init
- Select option 2 - Custom Template Location
- Enter gh:rts-rob/aws-sam-iterative-replacement-golang
- Provide a project name, e.g., hello-world
- Change into the created directory
- Build with
sam build
- Deploy with
sam deploy --guided
- You will need to provide your existing application root URL as the value for the
PassthroughTarget
parameter, e.g., https://api.anycompany.com. Do not include a forward slash"/"
at the end.
- You will need to provide your existing application root URL as the value for the
Now you have a sample application with Amazon API Gateway, Amazon DynamoDB, and AWS Lambda deployed and running in the region you specified. Your HTTP API will forward all traffic to your PassthroughTarget
except for the routes you explicitly define in your AWS SAM template.
Once deployed, implement your actual route logic one route and method at a time. Shift traffic to one completed route at a time, and monitor for any unexpected behavior.
Once you have iterated through all of your routes, congratulations! You've successfully migrated your monolith. You can shut down the underlying infrastructure, and refocus your ops efforts on improving performance for your customers.
Issue reports and pull requests to help improve these application templates are always welcome. Please see CONTRIBUTING.md.
This project is licensed under the MIT License.