AWS Lambda

AWS Lambda is a serverless compute service offered as part of Amazon Web Services. Learn how to set it up with Sentry.

On this page you'll get an overview how to install, configure and use Sentry in your AWS Lambda functions. Once set up, our SDK will automatically report error and performance data from your Lambda Functions. Issues in Sentry will automatically include cloudwatch data, function details and execution time measurements.

Depending on your preferences, you can install Sentry in your Lambda functions using the Sentry AWS Lambda Layer (recommended) or the Sentry AWS NPM package.

We generally recommend using the Lambda layer as it doesn't require you to deploy any Sentry dependency alongside your function. With the layer, you can achieve the same level of customization as with the NPM package. There are two reasons why you still might want to use the NPM package instead:

  1. You want to minimize lambda function size and tree-shake parts of the SDK code that you don't need. A related reason might be because you're transpiling your code and want to transpile your dependencies as well.
  2. You already use NPM packages and deploy node_modules with your function and you don't want to add a (or another) Lambda layer to your functions.

After installing the SDK, you might want to configure some parameters. Besides the common SDK configuration, you can also configure Sentry's Lambda Function handler wrapper to optimize function runtime overhead and timeout warnings.

Once set up, verify that Sentry is reporting errors correctly by throwing a sample error in one of your functions:

index.js
Copied
exports.handler = async (event, context) => {
throw new Error("This is a test error");
};
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").