BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Kappa: Simplifying AWS Lambda Deployments

Kappa: Simplifying AWS Lambda Deployments

This item in japanese

Mitch Garnaat has created a command line tool named Kappa that facilitates the deployment of ‘Lambda functions’ to AWS Lambda, a compute service that runs code in response to events and automatically manages the associated compute resources.

The Amazon Web Service (AWS) Lambda service allows code to be deployed on the AWS cloud computing platform and associated with events, such as a website click, new files appearing in an AWS S3 object storage bucket, or new data being written to an AWS Kinesis real-time stream processing instance.

AWS Lambda typically runs the code within milliseconds of an event occurring, and the service automatically manages the compute capacity, spins up necessary infrastructure and runs the code for each event. Currently AWS Lambda supports code written in Node.js, a platform built on Chrome’s JavaScript runtime.

Garnaat, author of the boto Python interface to AWS, created Kappa after discovering that the process of deploying code from a local development environment to AWS Lambda involved multiple manual steps that each utilised differing AWS services. Garnaat provides an example of the steps required to deploy a small JavaScript function to AWS Lambda that will be called whenever a record is written to an Amazon Kinesis instance:

  • Write the Javascript function (AWS Lambda only supports Javascript right now)
  • Create an IAM Role that will be used to allow the Lambda Function to access any AWS resources it needs when executing.
  • Zip up the Javascript function and any dependencies
  • Upload the zip file to the AWS Lambda service
  • Send test data to the Lambda Function
  • Create an IAM Role that will be used by the service invoking your Lambda Function
  • Retrieve the output of the Lambda Function from Amazon CloudWatch Logs
  • Add an event source to the Lambda Function
  • Monitor the output of the live function

Garnaat states that the goal of Kappa is to make it easy to deploy Lambda functions by simplifying the deployment process “[Kappa] tries to handle many of the fiddly details and hopefully lets you focus more on what your Lambda Functions are actually doing”

Kappa is executed from the command line, and the AWS Lambda service configuration is specified within a YAML file stored on the local file system. This configuration file specifies details such as an AWS profile that contains the required credentials for Kappa to utilise when interacting with AWS Lambda, the AWS region to which the code will be deployed, and the event source attributes that refer to the events driving the Lambda function.

Kappa automates the handling of security requirements associated with a Lambda function by utilising a CloudFormation template to manage AWS Identity Access Management (IAM) roles for the function’s execution and invocation. Garnaat states that using CloudFormation to handle the IAM functionality provides a transactional approach to creating and updating the roles and policies, and allows them to be version controlled using an SCM tool such as git.

Kappa provides commands to orchestrate the deployment and execution of code. The ‘deploy’ command triggers the creation of the required infrastructure stack, and zips and uploads the locally created Lambda function to AWS Lambda. The ‘add-event-source’ command can be used to associate the uploaded Lambda function to a specified event using the invocation role specified in the CloudFormation template.

Kappa also provides a ’tail’ command that finds the log group name and stream in the CloudWatch Logs service that contains the function output, and prints the most recent log events from that stream to the console.

If changes to roles, policies, or to the Lambda function itself are required, then the Kappa ‘deploy’ command can be called as required, and Kappa will take care of updating the CloudFormation stack and uploading the new version of the function to AWS Lambda.

Kappa can be installed using Python package index (PyPI), or installed manually by cloning the project’s Github repository and following the instructions on the AWS Advent blog. More details on the AWS Lambda service can be found on Lambda product page.

Rate this Article

Adoption
Style

BT