Small example of how to use AWS Lambda Layers to inject latency into AWS Lambda Functions
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Injecting Chaos to AWS Lambda functions using Lambda Layers

  • See the full blog post describing how to install and use this small chaos library here.

Building the zip package on a MAC (easy on Linux)

  • Regardless if you are using Linux, Mac or Windows, the simplest way to create your ZIP package for Lambda Layer is to use Docker. If you don't use Docker but instead build your package directly in your local environment, you might see an invalid ELF header error while testing your Lambda function. That's because AWS Lambda needs Linux compatible versions of libraries to execute properly.

  • That's where Docker comes in handy. With Docker you can very easily run a Linux container locally on your Mac, Windows and Linux computer, install the Python libraries within the container so they're automatically in the right Linux format, and ZIP up the files ready to upload to AWS. You'll need Docker installed first. (

  1. Clone the small chaos experiment library

    • run the following command:

      git clone
  2. Spin-up a docker-lambda container, and install all the Python requirements in a directory call .vendor

    • run the following command:

      $ docker run -v $PWD:/var/task -it lambci/lambda:build-python3.6 /bin/bash -c "pip install -r python/requirements.txt -t ./python/.vendor"
    • The -v flag makes the local directory available inside the container in the directory called working. You should now be inside the container with a shell prompt.

  3. Package your code.

    • run the following commands:
      $ zip -r ./python

Voila! Your package file is ready to be used in Lambda Layer.