Better Programming

Advice for programmers.

Follow publication

Member-only story

Simplify AWS Lambda Dependencies Using Layers

Jordan Chalupka
Better Programming
Published in
4 min readJul 14, 2019
Photo by Sebastian Alvarez on Unsplash

What Are Layers?

As serverless technologies become more popular, AWS continues to add new features to its serverless computing service Lambda. One of these new features was layers.

Layers make it possible to run Lambda functions with custom runtime code. One of the most exciting benefits that layers brought to Lambda, was the ability to run Lambda functions in any programming language.

However, another benefit added by layers comes in the form of simplifying dependencies in your Lambda functions. Before layers, deploying Lambda functions with dependencies, added an extra complexity when getting up and running in Lambda.

In short: Lambda layers offer a simple way to supply your Lambda function with dependencies.

The Problem

Today we will be creating a simple Lambda in Python.

Our Lambda function will receive a multidimensional array as input and output the dimensions of that array. Pretty simple, right!

Okay, let’s get started with some boilerplate:

This defines our Lambda handler to take an input event named array and return the number of dimensions in array.

Pretty trivial. Let’s get this code running in Lambda!

Head over to your AWS Console and create a new Lambda function. Be sure to select Python 3.7 as your runtime.

At first, you might be tempted to copy and paste your Lambda function into the AWS Console. It’s simple enough and you just want to test out this function that you wrote.

However, if you try this, you will receive the following error:

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Jordan Chalupka
Jordan Chalupka

Written by Jordan Chalupka

Software Engineer + Growth Hacker in Toronto

Responses (3)

Write a response