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?

已提問 1 個月前檢視次數 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
專家
已回答 1 個月前
profile pictureAWS
專家
已審閱 1 個月前
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

已回答 1 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南