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.
Please read more about this in my Medium blog post.
- Java 1.8+
- Apache Maven
- AWS SAM CLI
- Docker
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.
sam build
sam local invoke
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.
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.