AWS Lambda Layer (Node)

Learn how to set up Sentry with a Layer

You can also install Sentry using a Lambda Layer instead of adding @sentry/aws-serverless with npm or yarn. Import Sentry as usual:

Copied
const Sentry = require("@sentry/aws-serverless");

This installation method will not work if you are using webpack.

Then add the Sentry Layer by navigating to your Lambda function. Select Layers, then Add a Layer.

Specify an ARN tab as illustrated:

Finally, set the region and copy the provided ARN value into the input.

Select Region

You can also install a v7 version of the Sentry Lambda layer in case you cannot upgrade to v8. Modify and copy the provided ARN value for your region into the input, e.g. for region us-west-1 and the current v7 Lambda layer version 3:

Copied
arn:aws:lambda:us-west-1:943013980633:layer:SentryNodeServerlessSDKv7:3

You can use the v7 layer integration for node like this:

Copied
const Sentry = require("@sentry/serverless");

Sentry.AWSLambda.init({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",

  // We recommend adjusting this value in production, or using tracesSampler
  // for finer control
  tracesSampleRate: 1.0,
});

exports.handler = Sentry.AWSLambda.wrapHandler(async (event, context) => {
  // Your handler code
});
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").