Install the Sqreen Microagent for AWS Lambda Python functions

Closed Alpha

The Sqreen microagent for AWS Lambda Python functions is currently in closed alpha testing. Please email us at for more information.

  1. Sign up to create your Sqreen account.
  2. Fetch your organization token. From the Sqreen Dashboard, access Account Settings > Environments & Tokens. Your token begins with env_org_. Take note of the token.
  3. Set the following environment variable:
    export SQREEN_TOKEN="replace with your own token"
  4. Follow the instructions for one of the following options.

a. Retrieve the install script by downloading it.

curl -O

b. Install Sqreen as an AWS Lambda Layer with the following command:

sh layers

Note, you can use the desired AWS region or AWS profile using the environment variables AWS_REGION and AWS_PROFILE.

a. Insert the following configuration in your template.

    Type: String
    Description: Sqreen organization token

        SQREEN_TOKEN: !Ref SqreenToken
     - !Sub "arn:aws:lambda:${AWS::Region}:301725247889:layer:sqreen-for-python:12"

b. Deploy your application with a new parameter.

sam build
sam deploy --parameter-overrides "SqreenToken=${SQREEN_TOKEN}"

a. Modify your Terraform Lambda function resources to match the following.

variable "sqreen_token" {}
data "aws_region" "current" {}

resource "aws_lambda_function" "my_function" {
  function_name = "my_function"
  filename      = ""

  runtime = "python3.x"
  handler = "..."
  role    = "..."

  environment {
    variables = {
      SQREEN_TOKEN = var.sqreen_token

  layers = [

b. Apply the changes.

terraform apply -var="sqreen_token=${SQREEN_TOKEN}"

a. Modify your Zappa configuration and adapt the aws_environment_variables and layers fields.

    "dev": {
        "project_name": "my-zappa-application",
        "runtime": "python3.x",
        "aws_environment_variables": {
        "layers": [

b. Apply the changes.

zappa update dev