Skip to content

This repository provides a working, deployable, open source based, AWS Lambda handler and CDK Python code. This handler embodies Serverless best practices and has all the bells and whistles for a proper production ready handler.

License

Notifications You must be signed in to change notification settings

rubenfeito/aws-lambda-handler-cookbook

Repository files navigation

AWS Lambda Handler Cookbook (Python)

license PythonSupport codecov version github-star-badge issues

alt text

This project provides a working, open source based, AWS Lambda handler skeleton Python code including DEPLOYMENT code with CDK and a pipeline.

This project can serve as a template for new Serverless services - CDK deployment code, pipeline and handler are covered.

📜Documentation | Blogs website

Contact details | ran.isenberg@ranthebuilder.cloud

Elevate Your Handler's Code

What makes an AWS Lambda handler resilient, traceable and easy to maintain? How do you write such a code?

The project is a template project that is based on my AWS Lambda handler cookbook blog series that I publish in ranthebuilder.cloud and attempt to answer those questions.

This project provides a working, open source based, AWS Lambda handler skeleton Python code including DEPLOYMENT code with CDK and a pipeline.

The project deploys an API GW with an AWS Lambda integration under the path POST /api/service/.

The AWS Lambda handler embodies Serverless best practices and has all the bells and whistles for a proper production ready handler.

CDK Deployment

The CDK code create an API GW with a path of /api/service which triggers the lambda on 'POST' requests.

The AWS Lambda handler uses a Lambda layer optimization which takes all the packages under the [packages] section in the Pipfile and downloads them in via a Docker instance.

This allows you to package any custom dependencies you might have, just add them to the Pipfile under the [packages] section.

Serverless Best Practices

The AWS Lambda handler will implement multiple best practice utilities.

Each utility is implemented when a new blog post is published about that utility.

The utilities cover multiple aspect of a production-ready service, including:

  1. Logging
  2. Observability: Monitoring and Tracing
  3. Observability: Business Domain Metrics
  4. Environment variables
  5. Input validation
  6. Features flags & dynamic configuration
  7. Start Your AWS Serverless Service With Two Clicks

I've written 3 of the mentioned utilities (parser, feature flags and environment variables) and donated two of them, the parser and feature flags to AWS Lambda Powertools.

While the code examples are written in Python, the principles are valid to any supported AWS Lambda handler programming language.

This repository is the complementary code examples of my blog series "AWS Lambda Cookbook - Elevate your handler's code"

Getting started

Head over to the complete project documentation pages at GitHub pages at https://ran-isenberg.github.io/aws-lambda-handler-cookbook

Connect

Credits

License

This library is licensed under the MIT License. See the LICENSE file.

About

This repository provides a working, deployable, open source based, AWS Lambda handler and CDK Python code. This handler embodies Serverless best practices and has all the bells and whistles for a proper production ready handler.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 95.3%
  • Makefile 4.7%