dynamodb-geo.js icon indicating copy to clipboard operation
dynamodb-geo.js copied to clipboard

Can we use with aws-sdk v3?

Open ghost opened this issue 4 years ago • 8 comments

Hi. Can this library be used with aws-sdk v3?

ghost avatar Jun 13 '21 15:06 ghost

It cannot. Since I'm using this library in a Lambda function and want to minimize space by importing only the dynamodb bits, does anyone know how to avoid importing the entire SDK with const AWS = require('aws-sdk')? AWS SDK v3 adds support for a modular architecture, but this library isn't compatible with it yet.

csr avatar Jun 14 '21 09:06 csr

@csr I thought so. I like the API for v3, and personally use it, but I don’t think using v3 will decrease the container size, and maybe will increase it, since aws-sdk v2 is and always present in the container that a lambda function runs. Not sure, if not importing aws-sdk will have benefits.

ghost avatar Jun 15 '21 22:06 ghost

@omer-to v3 will decrease the container size if you only import a subset of the AWS SDK in your package.json, thanks to the new SDK modular architecture. For example you can just npm install @aws-sdk/dynamodb and the Lambda function will perform better that way especially with cold starts. See here.

csr avatar Jun 16 '21 07:06 csr

@csr Nope, the container size will not decrease, just the package size will decrease. The docker container that is created for a Lambda function to run already includes globally installed aws-sdk whether you import it or not. That’s why you can deploy your Lambda without aws-sdk package, and you will still be able to import it and use it, because the container already has it.

ghost avatar Jun 16 '21 08:06 ghost

It's not hard to add v3, but it's hard to do backward compatible in one package, I ever tried to add v3, but I think separate package would be ideal. I ever tried to add v3 for testing purpose.

nch3ng avatar Jun 18 '21 01:06 nch3ng

I refactored the library to use the AWS SDK v3 and released it as an npm package named dynamodb-geo-v3 here. Feel free to try everything out & open an issue in my repo, if something's not workin as expected. But please be aware that I did not maintain backward compatibility.

renet avatar Oct 03 '21 20:10 renet

here

@renet if I understand correctly, you mentioned dynamodb-geo-v3 is supposed to use AWS SDK v3 but from what I see it still uses the old APIs. Did I misunderstand or am I missing something?

alex-arzaghi avatar Oct 29 '23 00:10 alex-arzaghi

@alex-arzaghi This commit shows the refactoring. It's in a different repository, maybe you got that wrong. If you have any more issues with it, please report them there.

renet avatar Oct 29 '23 07:10 renet