Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Quickstart for debugging Python + AWS Lambda

A sample application for debugging Python apps deployed in AWS Lambda using Rookout.

Before following this guide we recommend reading the basic Python + Rookout guide

Rookout Integration Explained

To integrate the Rookout SDK (aka "rook") into your existing Python Lambda app, follow these steps:

  1. Add the pip dependency rook in the project folder.

  2. Wrap your lambda_handler function in our Rookout wrapper.

  3. Set your Rookout Token as an environment variable in the Lambda configuration.

Running on Lambda

  1. Make sure your python module is called to use our example.

  2. Uploading your function :

    • Zip Upload: In order to run your Rookout-wrapped function on Lambda, make sure the dependencies are downloaded and zip the folder (including all the modules installed by pip).
      zip -r .

    • aws-cli : Create a new Lambda function and update it like so :

      aws lambda create-function \
                  --region <REGION> \
                  --function-name rookout_lambda_test \
                  --zip-file fileb:// \
                  --role <ROLE-ARN> \
                  --handler lambda_function.lambda_handler \
                  --runtime python2.7 \
                  --environment Variables="{ROOKOUT_TOKEN=<org_token>,ROOKOUT_ROOK_TAGS=lambda}" \
                  --timeout 25

      If you do not have access to aws-cli, you can do this from the AWS console and follow the Amazon Documentation

    • Using Cloud9 IDE integrated tools.

    IMPORTANT: If you are building on a MacOS/Windows machine, pip will compile native binaries for this platform. AWS Lambda runs on Linux and thus needs the linux compiled binaries. To build AWS Lambda compatible native extensions, simply run the following command line:

    docker run -v `pwd`:`pwd` -w `pwd` -i -t lambci/lambda:build-python2.7 pip install rook -t .

    You can read more about building a local native extension in our blog.

  3. Set your Rookout Token as an environment variables in the Lambda configuration:

    • ROOKOUT_TOKEN : Your Organization Token
  4. Go to and start debugging !

Rookout Integration Process

We have added Rookout to the original project by:

  1. Installing the Rookout SDK: pip install rook -t . (installs module in root folder)

  2. Wrapping our function by using our Rookout lambda decorator as follows:

    from rook.serverless import serverless_rook
    def lambda_handler(event, context):
        return 'Hello World'
  3. Setting our Rookout Token as a Lambda environment variable: ROOKOUT_TOKEN

You can’t perform that action at this time.