Hello guys, I'm having an issue with Pulumi, AWS ...
# general
Hello guys, I'm having an issue with Pulumi, AWS and Lambda with NodeJS 14.x. Hope someone of you can help me with the problem There are two projects, one of them is a
npm library
and the other one is a
web service
, either the web service and the npm library have the following Pulumi dependencies: package.json -> "dependencies"
Copy code
"@pulumi/aws": "^4.23.0",
"@pulumi/awsx": "^0.32.0",
"@pulumi/pulumi": "^3.0.0",
The web service also dependes of the npm library. When i push changes to AWS with the command
pulumi up -y
everything works fine, but when i make a request to the ApiGateway that calls one of the created lambda functions i'm having this error output in Cloudwatch:
Copy code
Cannot find module '@pulumi/pulumi'
One of the functions in the npm library needs that dependency but i looks like Pulumi is excluding it because regardless the package.json shows that dependency it doesn't appear in node_modules. Anyone have an idea of what could be happening in that case? Thank you.
just to be clear, your web service is running pulumi?
The web service was build with Pulumi and is being deployed with Pulumi.
it's unfortunately not super clear what's happening here 😞 why is the web service bundling pulumi?
Because at runtime we need to get a stack reference, that login happens in the npm library.
are you using a magic function to create a lambda by any chance?
i don't think so, i am fairly new in this project
i just didn't know that i couldn't use a pulumi-library function at lambda-runtime
i've spent about a week with this error and i think the best option is to refactor to remove that dependency
Just wanted to be sure if using pulumi functions at lambda-runtime is considered a bad practice.
🙌 1
again, its hard to be able to determine what's going on here because there's really not information, but we explicitly strip pulumi functions from any uploaded lambda to reduce the size: https://www.pulumi.com/docs/intro/concepts/function-serialization/#determining-the-required-node_modules-packages
Copy code
Note that pulumi will not include @pulumi/... packages with the Lambda. These packages exist solely to provide deployment time functionality, and do not contain any code that can work properly at run time. They are automatically stripped from a Lambda both to prevent accidental usage and to help reduce the size of the uploaded Lambda.
I think that is the answer that i was looking for @billowy-army-68599. Thank you!!