Skip to content

AWS SDK v3 Support (v2 deprecation) #8575

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
throrin19 opened this issue Jul 18, 2023 · 26 comments · Fixed by #11548
Closed

AWS SDK v3 Support (v2 deprecation) #8575

throrin19 opened this issue Jul 18, 2023 · 26 comments · Fixed by #11548
Labels
Meta: Breaking Package: serverless Issues related to the Sentry Serverless SDK
Milestone

Comments

@throrin19
Copy link

Problem Statement

Actually, @sentry/serverless package use the aws-sdk v2. It results on this warnings when testing in local with serverless-offline :

(node:49034) NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023.
Please migrate your code to use AWS SDK for JavaScript (v3).
For more information, check the migration guide at https://a.co/7PzMCcy

With lambdas using the node18 runtime, the sdk available is the v3, not the v2. To be able to use the sdk in v2, it must be included in the package, which makes the size of each lambdas quite substantial.

Solution Brainstorm

Use the sdk v3. But, with that, we have the problem of compatibility between aws node runtime < node18 using the sdk v2 and aws node runtime >= node18 using the sdk v3

@Lms24
Copy link
Member

Lms24 commented Jul 18, 2023

Hi @throrin19 thanks for writing in!

Sounds like we can't upgrade to the v3 SDK at the moment without dropping support for Node <18 on AWS Lambda. So we can't do this without releasing a major and even then it partially goes against our philosophy of supporting old runtimes as long as possible. On the other hand, I get that this warning is concerning. I'm going to backlog this issue and add it to the "Up for Discussion" tasks for our next major.

@throrin19
Copy link
Author

Thanks for your response and I fully understand this complex problem

@alfaproject
Copy link

alfaproject commented Sep 6, 2023

You don't need node 18. We are using the new SDK with node 16 and I'm pretty sure it works in node 14 and possibly even earlier versions. There's nothing special about their code

P.S.: anyone that is using the old SDK is already receiving this:

(node:28720) NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023.
Please migrate your code to use AWS SDK for JavaScript (v3).
For more information, check the migration guide at https://a.co/7PzMCcy

@Lms24
Copy link
Member

Lms24 commented Sep 6, 2023

According to the v3 docs, Node 14 is the minimum. But according to @throrin19,

we have the problem of compatibility between aws node runtime < node18 using the sdk v2 and aws node runtime >= node18 using the sdk v3

Does this mean that v3 can only be used in Node 18 lambdas? I'm a bit confused by this and would appreciate some more insights. Furthermore, I'm not sure (and didn't find yet) what the minimum version of v2 was.

Our overall goal must be that we maintain support for all Node versions we currently maintain until we drop support in the Next major (TBD). If it is possible to accomplish this with when updating to the v3 SDK we can do this. However, I can't guarantee any time frame, given that we're swamped with tasks and serverless is pretty low on our list of priorities. PRs are defiitely welcome here ;)

Furthermore, we'll need to look at

// eslint-disable-next-line @typescript-eslint/no-var-requires
const awsModule = require('aws-sdk/global') as typeof AWS;
fill(awsModule.Service.prototype, 'makeRequest', wrapMakeRequest);

which patches a method of the AWS SDK. I don't know at the moment if this API changed in v3 and if/how we can patch both.

Thanks for the help!

@throrin19
Copy link
Author

throrin19 commented Sep 7, 2023

@Lms24 According to AWS documentation, AWS SDK v2 is available directly in lambda default layer in node version <= node14. For node >= 18 it's AWS SDK v3.

The problem is mainly in the optimization of the lambdas, and in particular the size of the lambdas.

Basically, the serverless framework won't integrate aws-sdk packages into the final build if they correspond to those provided by the default layer of the node version.

In our case, given that sentry-serverless uses sdk v2, if we decide to build on node <= 14, no worries, the sdk won't be included in the final code, we'll use the layer's sdk.

On the other hand, if you decide to build on node >= 18, you'll have to integrate the sdk v2 code, as it's not provided by default.

I don't know if I'm helping to clarify the problem.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Sep 7, 2023
@getsantry getsantry bot removed the status in GitHub Issues with 👀 Sep 13, 2023
@mydea mydea mentioned this issue Nov 9, 2023
@throrin19
Copy link
Author

Any news about that ? Aws just launch node 20 compatibility with lambdas and, according to the documentation :

Up until Node.js 16, Lambda’s Node.js runtimes included the AWS SDK for JavaScript version 2. This has since been superseded by the AWS SDK for JavaScript version 3, which was released in December 2020. Starting with Node.js 18, and continuing with Node.js 20, the Lambda Node.js runtimes have upgraded the version of the AWS SDK for JavaScript included in the runtime from v2 to v3. Customers upgrading from Node.js 16 or earlier runtimes who are using the included AWS SDK for JavaScript v2 should upgrade their code to use the v3 SDK.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Nov 22, 2023
@lforst
Copy link
Contributor

lforst commented Nov 22, 2023

Hi, coming in with a few infos:

  • The Sentry Serverless SDK doesn't require the aws-sdk at all. It's a dev-dependency. If it isn't installed the SDK should fail gracefully. Edit: This is wrong. The SDK uses aws-sdk but things should still not crash for v3.
  • The Sentry Serverless SDK only interacts with the aws-sdk by monkeypatching the package's makeRequest function to instrument outgoing requests made with that function. Everything else should work as expected in the future.
  • The Sentry SDK is compatible with Node 20.

@throrin19
Copy link
Author

If I remove sentry call, I don't have aws SDK v2 in my builded files

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Dec 11, 2023
@lforst
Copy link
Contributor

lforst commented Dec 11, 2023

@throrin19 Ok, that means you have the AWS SDK v2 installed locally and your bundler is pulling it in. This is not something we can fix.

@throrin19
Copy link
Author

throrin19 commented Dec 11, 2023 via email

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Dec 11, 2023
@lforst
Copy link
Contributor

lforst commented Dec 11, 2023

@throrin19 Feel free to share a reproduction example where the AWS SDK v2 is pulled in and we will take a look.

@throrin19
Copy link
Author

I created a project with the example here : https://github.com/Aquassay/test-sentry-serverless-aws-sdk

You can run analyze of a lambda with or without sentry to saw the difference. And the difference is like I said : with Sentry, we have an import of aws-sdk V2 by this code line :

const awsModule = require('aws-sdk/global') as typeof AWS;

This is the analyze without Sentry on the lambda (In my example, in TS with middy) :

image

And the analyze with Sentry :

image

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Dec 14, 2023
@lforst
Copy link
Contributor

lforst commented Dec 14, 2023

@throrin19 In your esbuild config you neither marked @sentry/serverless nor aws-sdk as external which is gonna pull everything into your bundle. This is not something we can prevent from within the SDK. This is addressed by configuring your application properly.

@throrin19
Copy link
Author

throrin19 commented Dec 14, 2023 via email

@AbhiPrasad
Copy link
Member

Will be released with 8.0.0.

@AbhiPrasad AbhiPrasad added this to the 8.0.0 milestone Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Meta: Breaking Package: serverless Issues related to the Sentry Serverless SDK
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants