Probably a basic question, but to double-check –  ...
# help
c
Probably a basic question, but to double-check –  • is the use of
aws-cdk
primarily for IaC and you should rely on
aws-sdk
to call functionality in lambdas? • if so, does
aws-sdk
need to be production dependency or can it still be a devDependency?
r
First point, correct. I'd look into using the version 3 sdk too, much more consistent. Second point, if using v2 I tend to include it so that I can fix the version rather than relying on the one that's included automatically in the lambda runtime
c
Perfect, thanks Ross
And @Ross Coundon, just to clarify – by include vs. not include do you mean having
aws-sdk
declared at all in package.json or whether it is included as a standard dependency or a devDependency?
r
I include as a regular dependency, more so that it's clearer from reading the package.json that it's something required by the app at runtime. I'm not sure there's actually much difference when it comes to the build process
c
Gotcha, thanks again
j
It only matters in that the
aws-sdk
is added to the bundle and that increases upload time (main be significant if the lambda is under heavy development) and lambda bootstrap time (normally marginal but...). Another advantage from using the V3 SDK is that it works so much better with tree-shaking tools. Try it and you'll see.
g
If your lambda uses a lot of dependencies or your bundle is too big you may reach the aws limit of 250 mb per lambda. And
aws-sdk
is a big dependencies.. a work around is to set is as devDependencies and use the lib from the runtime provisioned by aws already
c
Thanks @JP (junaway) & @Gabriel Araújo - to make sure I’m following correctly, if I’m using v3 of the SDK is your recommendation to still leave any add packages (e.g.
@aws-sdk/client-eventbridge
) as devDependencies?
j
If you use v3 then add it as a dependency, IMHO.