Skip to content

An AWS SAM application with gradual deployment of a Lambda function written in Java. The application uses an auto-generated AWS SAM pipeline and linear deployment preference of a new version of the Lambda function.

License

Notifications You must be signed in to change notification settings

rimironenko/aws-sam-gradual-deployment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

App

This project contains an AWS SAM application with AWS Java SDK 2.x dependencies. The application uses AWS SAM capability for a gradual deployment of Lambda functions and AWS SAM pipeline triggered by GitHub actions. The infrastructure is present on the picture given below. Architecture diagram

Please read more about this in my Medium blog post.

Prerequisites

Development

The generated function handler class just returns the input. The configured AWS Java SDK client is created in DependencyFactory class and you can add the code to interact with the SDK client based on your use case.

Building the project

sam build

Testing it locally

sam local invoke

Deployment

The generated project contains a default SAM template file template.yaml where you can configure different properties of your lambda function such as memory size and timeout. You might also need to add specific policies to the lambda function so that it can access other AWS resources.

To deploy the application, you can run the following command:

sam deploy --guided

See Deploying Serverless Applications for more info.

Traffic shifting after a deployment

PreTrafficHookHandler Lambda function validates the inftasrtucture before starting the traffic shifting. It takes the lifecycle status from the environemnt configuration, but can execute any custom business logic to decide if the traffic shifting can be started for a new Lambda version.

SAM template contains "DeploymentPreference" property for API Gateway Lambda handler that starts the traffic shifting as configured if the PreTrafficHookHandler reports success.

About

An AWS SAM application with gradual deployment of a Lambda function written in Java. The application uses an auto-generated AWS SAM pipeline and linear deployment preference of a new version of the Lambda function.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages