Hey there! I am trying to add a layer to a lambda ...
# help
j
Hey there! I am trying to add a layer to a lambda via an ARN. I haven’t yet been successful and wanted to see if anyone could provide more clarity about what I should be adding as the
externalModule
to bundle (example below)? Here are the docs I’m referencing: https://docs.serverless-stack.com/working-locally#using-lambda-layers
Copy code
new sst.Function(this, "test", {
      handler: "src/app/testLambda.lambdaHandler",
      bundle: {
        nodeModules: ["winston"],
        externalModules: ["SentryNodeServerlessSDK"] // also tried "@sentry/serverless"
      },
      layers: [
        lambda.LayerVersion.fromLayerVersionArn(this, "SentryLayer", "arn:aws:lambda:us-west-2:943013980633:layer:SentryNodeServerlessSDK:29")
      ]
    })
Also for more context, I’m trying to add a sentry layer. The docs I’m using are here: https://docs.sentry.io/platforms/node/guides/aws-lambda/layer/ Thanks in advance 😄
f
Hey @Janessa, can you shared the error you are getting?
j
Hi Frank! There isn’t an explicit error, I see the layer on the lambda in AWS console but when I invoke the lambda to get an error throw/caught, I don’t see anything in Sentry.
f
hmm.. the layer seems to be set correctly. The externaModules should be
["@sentry/serverless"]
, but that’s not likely the issue here.
You can also try the non-layer approach:
Copy code
new sst.Function(this, "test", {
      handler: "src/app/testLambda.lambdaHandler",
      bundle: {
        nodeModules: ["winston"],
      }
    })
This should also work, the sentry library is packaged along with your code instead of inside a layer.
If this does not work either… I’d look into Sentry and see if they have a verbose mode that shows if the error is indeed being logged.