While you could install Sentry as a dependency in your function, it’s better to add it as a layer. This way you can use it in multiple functions without having to install it in each one.
To do this follow the instruction here:
Note at the bottom the ability to specify the layer using an ARN. For me the ARN is this:
Follow instructions here:
I prefer not to include the traces option as I haven’t worked out a simple way to detect whether the function is running in dev or prod within the lambdas themselves yet.