Set up code for Lambda function

0

I've got a few Lambda functions set up & working as I'd like. The issue is that every time I make a change, I have to update my code, create a zip, upload the zip to an S3 bucket, and then pull the code into Lambda from there.

I'd really like to use the dashboard code editor, as what I'm doing is a) pretty simple but b) requires a bit of tweaking.

The reason I can't use the dashboard code editor, is because the node modules (which is only what's required for import AWS from 'aws-sdk';) is too large... it does appear you can install these in the dashboard, but, I haven't been able to do it.

Can anyone offer guidance?

asked 6 months ago287 views
2 Answers
2
Accepted Answer

Hello.

I think "aws-sdk" can be used by default with Lambda's Node.js, but what kind of modules are you specifically adding?
https://docs.aws.amazon.com/lambda/latest/dg/nodejs-package.html#nodejs-package-dependencies

For Lambda functions that use the Node.js runtime, a dependency can be any Node.js module. The Node.js runtime includes a number of common libraries, as well as a version of the AWS SDK for JavaScript. The nodejs16.x Lambda runtime includes version 2.x of the SDK. Runtime versions nodejs18.x and later include version 3 of the SDK. To use version 2 of the SDK with runtime versions nodejs18.x and later, add the SDK to your .zip file deployment package. If your chosen runtime includes the version of the SDK you are using, you don't need to include the SDK library in your .zip file. To find out which version of the SDK is included in the runtime you're using, see Runtime-included SDK versions.

If you can use AWS SAM, you can create "package.json" and create layers using SAM templates.
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-layerversion.html

profile picture
EXPERT
answered 6 months ago
profile pictureAWS
EXPERT
reviewed 6 months ago
0

the answer about working this way

import { S3Client } from "@aws-sdk/client-s3";

was the way forward... it's a bit more fiddly than just importing everything... but, well worth the trade off of not having to upload zip files

answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions