7 open source tools that make AWS Lambda better

Love the simplicity of function-as-a-service but hate the setup process? Look to these projects to ease AWS Lambda deployments

Serverless applications strip software down to the barest of essentials: one short snippet of code, invoked and scaled on demand. Serverless is just the ticket for smaller apps, like a simple API or a single webpage, that don’t need the management overhead of an entire server or virtual machine. A serverless system simplifies life for the developer, and delivers elasticity on a scale that fits the job.

AWS Lambda is among the best-known of the serverless systems out there, but like many things Amazon (and many things cloud) it can cut your fingers if you try to grasp it with bare hands. Here is a collection of tools, frameworks, and projects designed to make it easier to set up, deploy, and manage AWS Lambda functions.

AWS Serverless Application Model (AWS SAM)

Amazon has long been known for offering the infrastructure first and the tooling second. The AWS Serverless Application Model, introduced in late 2016 (roughly two years after AWS Lambda), is described by Amazon as an “open-source framework for building serverless applications” for AWS Lambda.

AWS SAM is essentially a way to generate AWS CloudFormation application definitions for AWS Lambda functions, with less work. Like Kappa (discussed below), you create a YAML template that defines your application, then the YAML is transformed into AWS CloudFormation declarations. SAM also provides a way to locally test the defined application, provides tools for stepping through AWS Lambda functions (in Node.js, Python, or Go), and works with Amazon’s CodeDeploy to support revisions to functions.

AWS Lambda Power Tuning

Tuning an AWS Lambda function’s cost/performance ratio can be tedious. For the best results, you need to gather data about the function as it runs, then make decisions based on the workload supplied to it. The AWS Lambda Power Tuning project helps remove some of that drudgery.

AWS Lambda Power Tuning deploys as an AWS Step Functions state machine. It takes in an AWS Lambda function and a range of power configurations, runs the function using each power configuration, and reports back on which configuration is generally the most cost-efficient for the job. Version 2.0 of AWS Lambda Power Tuning lets you optimize functions for either cost or speed.

Kappa

Kappa, named for the letter that comes before lambda in the Greek alphabet, is a Python toolset for easing deployment of AWS Lambda functions. Creating an AWS Lambda function involves many discrete steps: creating the function; configuring permissions, configuring policies and roles, uploading the function, running tests, adding event sources, and so on. Kappa automates the process.

You create a YAML file that describes your function and runtime environment, and supply a JSON file as test input. Unit tests run by way of Python’s nose, but any test runner can be swapped in. Kappa makes it easy to delete a function and remove its associated role/policy/event source information, so you can set up and tear down as part of a larger testing mechanism if need be.

One caveat: Kappa has not been revised in two years. The AWS Serverless Application Model project, also written in Python, provides a more complete and up-to-date feature set.

Lambda Warmer

When invoked, AWS Lambda functions run for a limited period of time (up to 15 minutes), then shut down. Whenever they need to be freshly spun up, functions can lag by up to several seconds. The Lambda Warmer project provides you with a way to keep AWS Lambda functions alive and avoid “cold starts” on a stand-alone basis.

Lambda Warmer, written in JavaScript, is a module that can be added to existing AWS Lambda functions. It intercepts warmup “pings” sent to a function and takes the appropriate actions—for instance, to handle initializing concurrent function instances if you use concurrency—while passing actual requests to the main logic. Note that Lambda Warmer doesn’t trigger the warmup action itself; for that you need a CloudWatch rule or some other regularly invoked mechanism.

Lambdoku

If you’re a longtime fan of Heroku and you want a Heroku-like experience with AWS Lambda, Lambdoku is for you. Lambdoku wraps the AWS Lambda API in a command-line interface with commands that resemble Heroku’s, and even emulates many of the Heroku behaviors like pipelines, config, and releases. One downside: Due to the way AWS Lambda processes configuration changes, Lambdoku cannot guarantee, as Heroku does, that operations will happen atomically.

OpenFaaS for AWS Lambda

The mission behind the OpenFaaS project is to “make it simple to turn anything into a serverless function.” “Anything” means any code written in any language and any runtime that runs in a Docker container. OpenFaaS converts the Docker container into a serverless function and the resulting app is scaled, managed, and route-controlled using Kubernetes. Thus OpenFaaS allows serverless functions to be deployed to any system (including public clouds) where Kubernetes is available.

Now the OpenFaaS developers are beta-testing a service provider add-on, OpenFaaS for AWS Lambda, or faas-lambda. With OpenFaaS for AWS Lambda, apps packaged for use in OpenFaaS can run interchangeably on AWS Lambda instances and Kubernetes. As the OpenFaaS developers note, less demanding functions can stay on AWS Lambda (even on the free tier), while more demanding functions can run on Kubernetes. OpenFaaS for Lambda is still in private beta, but the project is accepting registrations for an early preview.

Serverless Framework

Most of the projects described in this article focus exclusively on AWS Lambda. Serverless Framework casts a wider net, allowing developers to create and deploy serverless applications on AWS Lambda, Google Cloud, Microsoft Azure, Apache OpenWhisk, and Kubeless, which is a serverless framework for Kubernetes.

Using Serverless Framework, serverless functions are created via a CLI, with the configuration for the function stored in a generated, developer-editable YAML file. The CLI is also used to deploy, test, and invoke functions, retrieve logs, perform monitoring, and remove functions from deployment. You can create new functions from nothing, or build on one of the many examples available. Functions can also be packaged up into an artifact for later deployment.

Serverless Framework also attempts to map its own internal constructions as closely as possible to the features of the target platform. For instance, its “layers” feature maps to AWS Lambda layers.

Copyright © 2019 IDG Communications, Inc.