If you’re not already doing so, you’ll need to imp...
# general
If you’re not already doing so, you’ll need to import the module inside the body of the handler. In typescript, this is the
await import
Yep that seemed to work
or maybe not
Is there anything special I need to do to get node modules packaged in with the function
We should pick up your imported modules automatically... @white-balloon-205 may have more insight than I here.
Yes - any packages you depend on in code that gets serialized into a Lambda should be included in
automatically. If you are not seeing that - would be great if you could open an issue with details of your example so that we can investigate. Note that if packages are not getting included, you can explicitly include them using e.g.
pulumi config set cloud-aws:functionIncludePackages express
. See https://github.com/pulumi/pulumi-cloud/blob/master/aws/config/index.ts#L42 for a few details on this config setting.
Thanks guys, I'll give it a go and report back
I think I worked out whats happening. If I put this within my handler function
const jwt = await import('jsonwebtoken');
it actually packages the
module rather than the actual
module. Note that
is in my devDependencies
So removing
and changing the line to
const jwt = require('jsonwebtoken');
fixed the build but obviously the library becomes an
which is a bit annoying but I can deal with it.
Ahh - okay - that sounds like a bug. Opened https://github.com/pulumi/pulumi/issues/1567.
Thanks @white-balloon-205!!