claudia: Claudia requires aws-sdk dependency, AWS does not
- Expected behaviour:
Claudia should create
or update
a function that uses aws-sdk
without it being installed in node_modules
, especially when using the --use-local-dependencies
flag.
Lambda provides this dependency as part of the environment, so not installing it saves lambda disk space, and this practice is encouraged by Amazon. Clauda should not require that it is installed.
- What actually happens:
Error: Cannot find module 'aws-sdk'
...
cannot require ./lambda after clean installation. Check your dependencies.
- Steps to reproduce the problem:
Use aws-sdk
as a devDependency
, and try to update.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 34 (14 by maintainers)
I’m sure there are several solutions I as an app developer can implement to make a Lambda claudia-complaint. My point was that claudia should be able to handle any node lambda that runs in AWS. There shouldn’t be claudia-specific constraints. Its your tool and you can decide that this case is too much work for Claudia to try to tackle.
It’s just a little surprising to read that, and then read that I need to write special code for an otherwise functional lambda to be deployed using Claudia.
Claudia uses its dependencies locally, and you should not include Claudia as a production dependency, only as a development one. Claudi Bot builder does not use aws-sdk, so it does not need it.
If your code requires aws-sdk, and you do not want to deploy it, use it as an optional dependency (
npm install aws-sdk -O
) and then deploy using--no-optional-dependencies
, this will exclude AWS SDK from the final package.--use-local-dependencies
just copies whatever you have locally. It’s your job then to make sure development dependencies are not installed.@vbichkovsky I think that’s a bug with NPM then, it’s not really in scope of Claudia to solve it. We have to rely on NPM to package the right dependencies. Perhaps submit that as a bug report there?
if you lazy-load aws-sdk (eg inside a function, not in the requires at the start of a file), then it will not be required for loading the module, so you can achieve exactly what you want, use local deps and still not include aws-sdk. claudia just needs to load the module to get the config out, it does not need to execute it.
That’s the issue though, I want to
--use-local-dependencies
because its more efficient and deterministic than letting Claudia re-install everything. It’s also required under some cases, like using pre-installed binaries.You are telling me that if I want to
--use-local-dependencies
, that claudia does not and will not allow me to work without an optional dependency that Amazon encourages everyone to ignore.You are saying that the best practices used by Amazon are exclusive to the best practices used by Claudia. That’s a big deterrent to using Claudia.