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?

질문됨 한 달 전102회 조회
2개 답변
2
수락된 답변

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
전문가
답변함 한 달 전
profile pictureAWS
전문가
검토됨 한 달 전
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

답변함 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠