Hi, I'm running into some lambda invoking issues w...
# typescript
t
Hi, I'm running into some lambda invoking issues where it seems that no modules are being bundled? I've read through this explanation on github https://github.com/pulumi/pulumi-aws/issues/249#issuecomment-401563361 I have the following code:
Copy code
import { holdingQueue } from './infrastructure/holding-queue'

holdingQueue.onEvent(
    'lambda-dev-holding-queue-event',
    async () => {
        let pulumi = await import('@pulumi/pulumi')
        let config = new pulumi.Config('apple-news-syndication')
        console.log(config.require('masthead'))
    },
    { batchSize: 1 },
)
and on the invoking of the function in AWS I'm getting the following error...
Copy code
2019-08-22T08:15:19.797Z 516f4272-0d5e-5549-b81b-17aa5c18ea49
{
    "errorMessage": "Cannot find module '@pulumi/pulumi'",
    "errorType": "Error",
    "stackTrace": [
        "Function.Module._resolveFilename (module.js:547:15)",
        "Function.Module._load (module.js:474:25)",
        "Module.require (module.js:596:17)",
        "require (internal/module.js:11:18)",
        "Promise.resolve.then (/var/task/__index.js:30:53)",
        "<anonymous>"
    ]
}
It looks like my node_modules aren't being uploaded to the lambda or is this expected?
t
pulumi
modules are excluded from the upload by design. Why do you need it inside the lambda body?
You should retrieve config outside the lambda, and then close over it
pulumi.Config
won't work in lambda anyway
t
ahh yup, i've just come across this in the documentation 🤦 thanks for replying!!
t
pulumi is mostly valid only within the context of CLI. and it's quite a heavy package, so it's excluded to save on upload size, memory, cold start, etc.
You should be able to do
const v = config.require('masthead')
outside and then
v.get()
inside the body.
t
legend @tall-librarian-49374 thank you very much
t
have fun!