Lambda Layer Management with the IOpipe CLI

Erica Windisch
IOpipe Blog
Published in
4 min readAug 27, 2019

--

Back in November 2018, we were launch partners with AWS for the AWS Lambda Layers feature. We immediately launched layers for our supported runtimes that provided whole-event observability and instrumentation with IOpipe without code modifications.

We found that layers alone did not sufficiently solve the story for our users.

Introducing the IOpipe CLI

We have written a tool for Python 3.6+ which works on the CLI and allows users to manage IOpipe on their functions.

This tool is being initially released with the following features:

  • List functions (and filter for installed/uninstalled functions)
  • Installation and configuration of IOpipe on AWS Lambda Functions
  • Updates and management
  • Removal of IOpipe from AWS Lambda Functions
  • Bulk installation and removal

The IOpipe CLI is designed to be compatible with the serverless-iopipe-layers plugin.

Installing the tool

Utilizing a pip associated with Python 3.6 or higher, run:

$ pip3 install -g iopipe

You can confirm that the tool is installed by running which iopipe.

Configuring the tool

The only configuration specific to the IOpipe tool itself is configuration of the IOPIPE_TOKEN environment variable. You should obtain your project token from the IOpipe dashboard and set IOPIPE_TOKEN in your environment, ideally via ~/.profile or similar. Alternatively, you can pass any CLI command the -t <TOKEN> parameter.

To manipulate resources on AWS, we depend on the same configuration as the AWS CLI tool, which need not be installed, but will simplify configuration and is something we generally recommend for serverless developers to have in their environment.

Once the AWS CLI tool is installed it can be configured with aws configure.

If not installing the AWS CLI, you can simply add the CLI configuration to your ~/.aws directory as described in the CLI documentation:

~/.aws/credentials:

[default]
aws_access_key_id=EXAMPLE_ID
aws_secret_access_key=EXAMPLE_KEY

Getting Started with the IOpipe CLI

Now the the tool is installed and configured, lets use it!

Listing functions

Most of the commands in the CLI operate on function ARNs or function names. Obtain a list of those functions with the following command, which also informs you of the status of IOpipe on those functions:

iopipe lambda list

Note that the CLI cannot currently detect if a function has been manually instrumented with IOpipe with a non-layer based approach. The CLI is compatible with functions where IOpipe has been installed via layers manually, through the CLI, or via the serverless-iopipe-layers plugin.

Listing functions with a filter

It can be useful to filter out functions where IOpipe is already installed:

iopipe lambda list -f not-installed

Valid filters are “all”, “installed”, and “not-installed”.

Installing IOpipe to a function

To install IOpipe on a function execute:

iopipe lambda install -f <function-arn>

This command installs IOpipe by adding the layer, adding environment variables, and also changes the entrypoint handler for the function. IOpipe wraps your handler and automatically invokes your handler as originally deployed.

Removing IOpipe from a function

This command will remove the IOpipe layer and restore the function to its original configuration.

iopipe lambda uninstall -f <function-arn>

Updating the IOpipe library in a function

The install feature automatically prevents accidental upgrades or updates of a function to a newer IOpipe layer. This safeguard is disabled by passing the -u parameter.

iopipe lambda install -u -f <function-arn>

Again, this update tool is compatible with the serverless-iopipe-layers plugin.

Bulk installations and updates

The IOpipe CLI has been designed for scriptability. Here’s an example of scripting a bulk install and update:

iopipe lambda list -q | xargs -n1 iopipe lambda install -u -f

Known Limitations

The tool is fantastic, but does have some limitations:

  • We support most runtimes on AWS, but due to limitations of the AWS architecture, NodeJS support is only for 10.x+. we do not support Node 8.10. We recommend that NodeJS 8.10 users utilize one of our plugins for the serverless framework or manually add the IOpipe wrapper and library to their project.
  • Updating functions using the CLI will cause Cloudformation stack drift. We have experimental code which solves this, enabled by a feature-flag.

Help and support

If having trouble with the IOpipe CLI tool, please reach out to our team via community Slack or email. We’d love to get your feedback and assist you with any difficulties. We’re also preparing to launch a web-based experience, so stay tuned!

About IOpipe

As the leader in serverless dev tooling for monitoring and observability, IOpipe offers real-time visibility into the most granular behaviors of today’s serverless applications on AWS Lambda.

Founded in 2016 by Erica Windisch and Adam Johnson, IOpipe reduces debugging time from hours to seconds, delivers transparent insights into the behaviors and performance of your serverless functions, and reduces risk for enterprises shifting to serverless.

Working with global brands like Matson, Rackspace, and APM Music, IOpipe empowers engineering teams to deliver with confidence, debug intelligently, and get busy building the impossible.

In other words, IOpipe makes it a lot more fun to be a developer. Visit www.iopipe.com to learn more and try it for free.

--

--

Building Streaming AI/ML | Cloud Computing Pioneer | Serverless Architect | Observability Founder & CTO