awslabs / llrt

LLRT (Low Latency Runtime) is an experimental, lightweight JavaScript runtime designed to address the growing demand for fast and efficient Serverless applications.
Apache License 2.0
7.76k stars 342 forks source link

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

Closed richarddavison closed 4 weeks ago

richarddavison commented 3 months ago

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

nabetti1720 commented 3 months ago

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 :)

tmokmss commented 2 months ago

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

riywo commented 1 month ago

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.

richarddavison commented 1 month ago

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 commented 4 weeks ago

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