We have an API built using the AWS serverless framework. Here we are using a lot of aws services in our functions and currently using aws-sdk v2. Now I want to migrate it to use aws-sdk V3 with minimal code changes.
In most of the aws documentation/documents available on the internet, the following steps are mentioned if we want to continue using v2 commands in v3.
If I do this as per the .getObject() method, the way the response is sent changes. It used to be buffer, now it's ReadableStream. So, my code breaks here.
If I want to use v2 commands in v3, do I need to change the code that handles the response?
When you upgrade to AWS SDK V3 for JavaScript, it is a new API. When you use the V3 API in your project, do not attempt to use V2 calls. If you do this, your code will be inaccurate and may be broken like you are seeing.
Instead update your code to use V3 logic and calls. See the new API reference to learn about the V3 API:
https://docs.aws.amazon.com/AWSJavaScriptSDK/ v3/latest/preview/
Here is a migration guide to help you.
https://github.com/aws /aws-sdk-js-v3/blob/main/UPGRADING.md