You can use AWS Lambda Layers to easily add IOpipe to your functions without having to modify your code directly.  There are multiple ways to add layers to your functions.  Below are examples of the most common setup methods:

Latest Lambda Layer ARNs

IMPORTANT: The region where your function is deployed must match the region where you source the layer. 

Setup Layers using the AWS Console

  1. Login to the AWS Console and navigate to the function you'd like to enable with IOpipe.  Click on Layers 

2. Click on Add a layer 

3. Select Provide a layer version ARN  and enter the latest IOpipe layer for the runtime matching your function.  Our ARNs found above.

4. Back on the Function overview page, enter iopipe.handler.wrapper (python) or @iopipe/iopipe.handler  (Node.js) in the Handler field.

5. Under the Environment Variables  section, add IOPIPE_HANDLER and your IOPIPE_TOKEN  (your token can be found in in your account here.).  IOPIPE_HANDLER  should match your function handler name.

6. Save your function, and you're all set!  You should be able to log into the dashboard and see new invocations showing up within seconds.

Using AWS Lambda Layers with Serverless Framework

Simply add IOPIPE_HANDLER  and IOPIPE_TOKEN  environment variables, specify the layer ARN (see above), and set the handler to iopipe.handler.wrapper in Python or @iopipe/iopipe.handler  in Node.js

See our full docs for Examples in Node.js
Example serverless.yml: (Python) 

  name: aws
  runtime: python2.7

      IOPIPE_HANDLER: handler.hello

      - schedule: rate(5 minutes)
    handler: iopipe.handler.wrapper
      - arn:aws:lambda:us-east-1:146318645305:layer:IOpipePython:9

Setup AWS Lambda Layers using SAM

    Type: 'AWS::Serverless::Function'
      CodeUri: s3://sam-demo-bucket/
      Handler: iopipe.handler.wrapper
      Runtime: python3.6
        - arn:aws:lambda:us-east-1:123456789101:layer:layer1:1
        IOPIPE_HANDLER: your_function_handler.hello
        IOPIPE_TOKEN: your_token

It is important to note that three changes are made here compared to a standard SAM template:

  1. The Layers  field specifies the IOpipe layer to add to the function
  2. The environment variable IOPIPE_HANDLER  is set to your function’s handler method.
  3. Your IOPIPE_TOKEN  can be found in the IOpipe dashboard here.
  4. The Handler parameter is set to iopipe.handler.wrapper , instrumenting the module specified by the IOPIPE_HANDLER environment variable.

Further Reading

For more in depth information on Layers, check out these helpful articles:

Did this answer your question?