llrt icon indicating copy to clipboard operation
llrt copied to clipboard

Example on how to use non-bundled AWS SDK Clients & Utils

Open richarddavison opened this issue 1 year ago • 4 comments

We lack an example on how to use clients and SDKs that are not provided with LLRT.

richarddavison avatar Mar 20 '24 07:03 richarddavison

Hi @richarddavison, I think this initiative will make LLRT more user-friendly.

From what I have worked on locally, here are some points to consider:

  1. When adding a new @aws-sdk module, which version should I adopt?
  2. How do I prove that the module I want to bundle is "popular" and get approval for bundling?

I can't contribute directly to this issue because I can't write English, but I would like to contribute by following the documentation and working on the @aws-sdk/lib-storage bundle.

Please note that this text was translated by DeepL :)

nabetti1720 avatar Mar 20 '24 23:03 nabetti1720

Hi, I tried using client-ecs in LLRT, and managed to get it working.

The main points were:

  1. set bundle target platform to browser
  2. pass credentilas and region explicitly from Lambda environment variables
  3. mark uuid as external

Here's the actual code that I used: https://github.com/tmokmss/cdk-lambda-llrt/pull/4/files

tmokmss avatar Apr 13 '24 15:04 tmokmss

When I wanted to use LLRT as a runtime for CLI, the ideal platform would be node even though LLRT doesn't support full Node.js features. Why does it require to set browser?

Also, bundled SDKs are hard to control their versions by users. It would be better to provide flexibility to let users decide whether they want to import SDKs explicitly, or use the bundled versions.

riywo avatar May 18 '24 09:05 riywo

Hi @riywo. Thanks for your comment, these are valid concerns .LLRT provides SDKs for since they have been optimized specifically for optimal performance on Lambda (with some dependencies replaced with Rust implementations, such as XML parsing). The reason why we target browsers is that the browser API more closely matches what you get out of the box with LLRT, and wouldn’t work with AWS SDK otherwise (without explicit config, mainly due to the lack of http and https modules). We’ll update the repo with an example on how to add non-provided SDKs. We may also add a non-bundled build of LLRT in the future (already possible to do if building from source with a feature flag). Hope this makes sense.

richarddavison avatar May 18 '24 10:05 richarddavison

Fixed in: https://github.com/awslabs/llrt/pull/410

richarddavison avatar Jun 06 '24 18:06 richarddavison