https://pulumi.com logo
Title
e

elegant-pager-5412

04/27/2021, 2:45 PM
When using the
CallbackFunction
to define lambdas, there is a major issue with the scoping. The generated code is exporting the entire callback
exports.handler = __f0
. While it should be fine, it leaves no room for us to open sockets/connection in the “global” lambda scope, but only in the invoked code which is a bad practice. Is there any way to solve this? Essentially, I want something like:
exports.handle = __f0;

// Some connection code:
AWSLambda.init({...}) // sentry

function __f0(...) {
  // ...
}
For whomever falls into this pitfall, the answer is using the
callbackFactory
property instead of the
callback
one and make that callback return another callback