dynamodb-geo.js
dynamodb-geo.js copied to clipboard
Can we use with aws-sdk v3?
Hi.
Can this library be used with aws-sdk v3?
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 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.
@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 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.
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.
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.
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 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.