Skip to content

Include aws-sdk-js-v3 clients in the Lambda runtime. #2149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Mar 17, 2021 · 9 comments
Closed

Include aws-sdk-js-v3 clients in the Lambda runtime. #2149

ghost opened this issue Mar 17, 2021 · 9 comments
Assignees
Labels
closed-for-staleness feature-request New feature or enhancement. May require GitHub community feedback.

Comments

@ghost
Copy link

ghost commented Mar 17, 2021

Related Problem

Decrease the uploaded Lambda ZIP by providing the client libraries in the runtime container, just as aws-sdk v2

I have a Lambda function which is triggered with DynamoDB streams, and the following is the only import in my function:

import { DynamoDBClient } from '@aws-sdk/client-dynamodb'

The uploaded ZIP function takes 4.8 MB. This is too much and removes the benefit of using modularized v3. I just tried out excluding the packages if v3 is provided in the runtime environment just as v2, i.e., aws-sdk.

In that case, I cannot see a benefit of using aws-sdk v3.

@ghost ghost added the feature-request New feature or enhancement. May require GitHub community feedback. label Mar 17, 2021
@adcreare
Copy link

I couldn't agree more. If V3 is actually released and whats more, "recommended", then it should be in the lambda runtime by default, but that would require the lambda service team to do work plus I suspect the V3 sdk is still a little to "beta" right now.

@ghost
Copy link
Author

ghost commented Apr 16, 2021

@adcreare I guess we should basically provide our own container image for the Lambda, and instead of putting aws-sdk, we can put the relevant v3 packages that the running Lambda will need. Not an expert on this, but the size of the container affects the cold starts too, I guess decreasing it by removing the v2 and putting the necessary packages, it will be better.

@philiiiiiipp
Copy link

@omer-to Afaik adding a layer for the lambda function would not replace the image the lambda function is running in ( which contains the aws-sdk v2 ), it would just add another layer on top.

I googled a bit and found an article exploring cold starts and lambda layers, I don't think it says much for this use case because it is not clear what the layer does and it uses java, but at least it shows no immediate addition to the coldstart. I would assume though that no matter where the sdk is located it will add to the coldstart.

@ghost
Copy link
Author

ghost commented Apr 17, 2021

@philiiiiiipp I didn’t mention anything about adding a layer, but rather providing container image?

@philiiiiiipp
Copy link

Oh I see, for some reason I just assumed you meant layers. This is quite interesting, especially to check how the coldstart is affected by using this over their provided runtimes.

@adcreare
Copy link

my understanding is adding your own container image is also result in longer cold starts. AWS have cloud9 editor of building simple lambdas inside a lambda function, if the aws sdk wasn't included by default that wouldnt be possible.
My guess is they'll add an option or import both v2 and v3 into the lambda runtime.. I don't see how they can do anything else without changing a bunch of things and invalidating a bunch of documentation they had for authoring quick lambdas.
When that will happen? who knows....

@dphang
Copy link

dphang commented Jun 19, 2021

This would be great to have, also hopefully in Lambda@Edge too (not sure if it's different, since I know Lambda@Edge has more limitations)

One current solution to the size problem we did (in our open source project): if you are just importing one client like DynamoDB, you can use something like Rollup to reduce the amount of code included by removing unused code for all other clients.

For example, for s3 client only it ended up including around 200 KB of code (uncompressed, unminified), which is still reasonable.

@kuhe
Copy link
Contributor

kuhe commented Jan 26, 2023

@kuhe kuhe added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jan 26, 2023
@github-actions github-actions bot added closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jan 31, 2023
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
closed-for-staleness feature-request New feature or enhancement. May require GitHub community feedback.
Projects
None yet
Development

No branches or pull requests

5 participants