dynamodb-toolbox icon indicating copy to clipboard operation
dynamodb-toolbox copied to clipboard

Support AWS SDK for JavaScript v3

Open fboudra opened this issue 4 years ago • 36 comments

it will be nice to switch to the modularized AWS SDK for JavaScript v3 (https://github.com/aws/aws-sdk-js-v3) since it reached gamma status. AWS Amplify is already using it.

dynamodb-toolbox doesn't require the full AWS SDK and will reduce the size of the bundle.

FWIW, it's a bit premature since AWS SDK for JavaScript v3 doesn't support DocumentClient yet.

fboudra avatar May 27 '20 17:05 fboudra

I was under the impression that v3 would have the same semantics as v2, just a different import method. If that's the case, I don't think any changes will be needed, especially since v0.2 of this library just requires the DocumentClient.

jeremydaly avatar Jul 10 '20 21:07 jeremydaly

I'm just trying this out today and sadly this doesn't seem to be the case.

DocumentClient doesn't seem to be part of https://github.com/aws/aws-sdk-js-v3 anymore and the API for DynamoDB in "@aws-sdk/client-dynamodb" seems to be at least slightly different to the one DocumentClient was providing.

waynerobinson avatar Jan 06 '21 04:01 waynerobinson

Yes, we discovered this right after v3 was released. Still looking for suggestions for handling this, but it would be really nice if AWS would reimplement the DocumentClient.

jeremydaly avatar Jan 06 '21 13:01 jeremydaly

Would the easiest option in the meantime be to create a proxy for DocumentClient?

I'll have some spare time over the next couple of weeks to see if I can add if you think it's a reasonable option.

waynerobinson avatar Jan 06 '21 20:01 waynerobinson

It’s either that, or we build the marshaling and unmarshalling into the platform.

jeremydaly avatar Jan 06 '21 23:01 jeremydaly

Marshaling is present in the @aws-sdk/util-dynamodb module, if that helps.

waynerobinson avatar Jan 07 '21 00:01 waynerobinson

Yup. The question is do we make that a dependency? We could do that and then require the user to pass in the v3 DynamoDB client like we do currently with the DocumentClient (so they could still instrument it). Of course, as soon as we build that, AWS will release an update with a DocumentClient. 🤦‍♂️

jeremydaly avatar Jan 07 '21 00:01 jeremydaly

Given the separate packages, could v2 and v3 coexist and the library auto-detect (or have a new mechanism for passing DDB for v3) which version is being used?

waynerobinson avatar Jan 07 '21 00:01 waynerobinson

Although this is one of the best libraries out there, the inability to use the latest SDK version that drastically reduces the bundle size for AWS lambda functions block people from installing this package. The upgrade process is not straightforward; however, it is very unpleasant to see such a great product that cannot catch up with the updates AWS even releases NodeJS 14 official support now, so it would be awesome to see this library as a community standard going forward.

rati-dzidziguri avatar Feb 06 '21 19:02 rati-dzidziguri

The issue with v3 is that there isn’t a DocumentClient, which is what this library uses under the hood. I’ve already built some prototypes that use v3 and apply marshall/unmarshall in the library, but this would create a massive breaking change. I was hoping that v3 would have a DocumentClient before GA, but unfortunately, that didn’t happen.

jeremydaly avatar Feb 06 '21 23:02 jeremydaly

I can confirm in other projects; we have been using V3 without notable issues. The marshall/unmarshall indeed is the recommended way from AWS ATM. and is the one we have been referring to as well and can say it works without issues.

Would you please let us know what challenges the library is facing so that we as a community might try to help and support you in this migration journey?

rati-dzidziguri avatar Feb 07 '21 00:02 rati-dzidziguri

I can confirm in other projects; we have been using V3 without notable issues. The marshall/unmarshall indeed is the recommended way from AWS ATM. and is the one we have been referring to as well and can say it works without issues.

Would you please let us know what challenges the library is facing so that we as a community might try to help and support you in this migration journey?

How have you been doing transactions with v3 without the DocumentClient?

aecorredor avatar Feb 12 '21 16:02 aecorredor

V3 has only a single concept and everything comes down to DynamoDBClient and Send Method. for the transaction we used the instance of a TransactWriteItemsCommand which accepts TransactWriteItemsCommandInput

rati-dzidziguri avatar Feb 13 '21 13:02 rati-dzidziguri

It looks like they (@trivikr) are "prioritising" DocumentClient in v3.

Considering it's popularity in terms of reactions, and the comments on DocumentClient support - we should consider prioritizing it. I'll raise this request in our planning meeting.

Might be worth waiting to see what they do with this before investing any significant effort.

However, I don't know if this defeats the point raised above (taken from the experimental PR for DocumentClient put):

We're not planning to publish modular implementation of Document Client as of now, as that would not be straightforward.

V3 doesn't seem complete yet.

darbio avatar Feb 13 '21 21:02 darbio

We're not planning to publish modular implementation of Document Client as of now

The modular implementation was added in c29b57d (#2031)

Having said that, this is still an experimental changes and have to be reviewed within the team. Do comment on the PR if you have ideas on anything can be done better or differently.

trivikr avatar Feb 14 '21 01:02 trivikr

This PR has been merged today, so v3 got DocumentClient.

https://github.com/aws/aws-sdk-js-v3/pull/2097

murbanowicz avatar Mar 05 '21 19:03 murbanowicz

I'll need to check the compatibility with the library!

jeremydaly avatar Mar 05 '21 21:03 jeremydaly

There is no update on this topic, even though many other libraries already implemented this. OneTable is already compatible with SDK3, and AWS released an update. Any ETA?

rati-dzidziguri avatar Mar 14 '21 12:03 rati-dzidziguri

@rati-dzidziguri there's a few issues as mentioned in this thread that definitely increase the complexity on getting this implemented in this library however, I'm sure Jeremy would be happy to review a PR solving this if submitted.

waynerobinson avatar Mar 14 '21 13:03 waynerobinson

Do we have a plan for this? The implementation in AWS/aws-sdk-js-v3#2097 is not compatible with this library.

I think we should not rely on documentClient and use marshal/unmarshal instead as it is the recommended path forward by AWS.

If we can agree on the path forward for this library, I am happy to implement it and create a PR.

adikari avatar Mar 21 '21 01:03 adikari

What benefits does v3 bring for us? Bundle size? Is there anything else? Anything we need from v3 that v2 doesn't already do?

Would the effort be better spent getting this library to v1 and then adding support for v3 after?

We haven't got a stable version of this library yet and there is a lot of feature spread which needs fixing prior to v1.

darbio avatar Mar 21 '21 02:03 darbio

Here is the my example problem statement :

I have a service and I am using eventbridge and dynamodb. I want to use version 3 aws sdk to reduce the bundle size. I used eventbridge module. Now, I want to update to use dynamodb module. But I can't as I am dependent on dynamodb toolbox and it depends on aws sdk.

As we are not yet to version 1 and not to the stable release yet, to me it makes sense to use the optimised version of aws sdk.

adikari avatar Mar 21 '21 03:03 adikari

Is it just bundle size that is the driver for updating to v3, or is there something else?

Does v2 have bugs that are fixed in v3? Etc.

I agree that it would be nice to use v3 and I agree that using un/marshall is my (totally uneducated and based upon the AWS media releases) preferred choice, however I just want to see this library get to v1 sooner rather than later.

darbio avatar Mar 21 '21 08:03 darbio

Any update on this?

rati-dzidziguri avatar Apr 14 '21 20:04 rati-dzidziguri

team any input or update regarding SDk3 support?

rati-dzidziguri avatar Nov 15 '21 12:11 rati-dzidziguri

Is there any update? I can see an open PR for a migration to the v3 SDK but it's been open for months now.

alexedwardjones avatar Dec 18 '21 14:12 alexedwardjones

@jeremydaly would love to here your thoughts on this. Would be nice to know if this is in roadmap or not.

adikari avatar Apr 07 '22 11:04 adikari

https://www.npmjs.com/package/@aws-sdk/lib-dynamodb

rati-dzidziguri avatar Apr 07 '22 12:04 rati-dzidziguri

Or: https://www.npmjs.com/package/dynamodb-onetable

mobsense avatar Apr 07 '22 20:04 mobsense

Yes, this is coming. We've been waiting on our migration to v0.4 that does automatic type inferencing. This should be ready soon.

jeremydaly avatar Apr 07 '22 20:04 jeremydaly

I like the way that typedorm have implemented this, with an abstraction that allows you to choose v2 or v3. It's quite neat.

darbio avatar Apr 08 '22 02:04 darbio

@jeremydaly How should I use the v3 client? I am getting type errors

image

ShivamJoker avatar Apr 24 '22 11:04 ShivamJoker

@jeremydaly How should I use the v3 client? I am getting type errors

image

You don't... yet.

darbio avatar Apr 24 '22 22:04 darbio

How much more time will it take for V4 to be released? And what are the changes we are looking for, I might try to send a PR

ShivamJoker avatar Apr 25 '22 04:04 ShivamJoker

How much more time will it take for V4 to be released? And what are the changes we are looking for, I might try to send a PR

It's been in the pipeline for a while, so hopefully we're close! I think the code was done but unmergeable. If you really need to use v3 have a look at TypedORM.

PS, it's v0.4 not v4. We haven't made it to v1 yet. Hopefully we're also close to that!

darbio avatar Apr 25 '22 04:04 darbio

v0.4 is finally live! Conversion to the v3 SDK is a high priority.

jeremydaly avatar Jul 05 '22 19:07 jeremydaly