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
8.07k stars 357 forks source link

ReferenceError: Error resolving module '/var/task/@aws-sdk/client-eventbridge' #2

Closed ymwjbxxq closed 11 months ago

ymwjbxxq commented 11 months ago

Hello,

Lambda config:

  Function:
    MemorySize: 256
    Architectures: ["arm64"]
    Runtime: provided.al2
    Layers:
      - !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:layer:LLRT:1

Deployed with

    Metadata:
      BuildMethod: esbuild
      BuildProperties:
        External:
          - '@aws-sdk/client-eventbridge'
          - '@aws-sdk/client-dynamodb'
          - '@aws-sdk/util-dynamodb'
        Minify: true
        Target: "es2020"
        Sourcemap: false
        EntryPoints: 
          - list.ts

Packages:

  "dependencies": {
    "@aws-sdk/client-dynamodb": "^3.433.0",
    "@aws-sdk/util-dynamodb": "^3.433.0",
    "@aws-sdk/client-eventbridge": "^3.433.0",
    "uuid": "^9.0.1"
  }

Log:

INIT_START Runtime Version: provided:al2.v25 Runtime Version ARN: arn:aws:lambda:eu-central-1::runtime:dce29199fb5887a2c4fceaa2f34d395ba43a74a6895b381cb9383b1c7f3b5875
Binary launched
Decompressing using 2 threads
Extraction time: 13.7280 ms
Extraction + write time: 18.8690 ms
Starting app
ReferenceError: Error resolving module '/var/task/@aws-sdk/client-eventbridge' from '' at <anonymous> (/var/task/insertToSync.js:1:614)
START RequestId: 234d277d-adc9-58b0-a831-7acab3e3ad38 Version: $LATEST
Unknown application error occurred Runtime.Unknown
END RequestId: 234d277d-adc9-58b0-a831-7acab3e3ad38
REPORT RequestId: 234d277d-adc9-58b0-a831-7acab3e3ad38 Duration: 362.75 ms Billed Duration: 363 ms Memory Size: 128 MB Max Memory Used: 12 MB
richarddavison commented 11 months ago

Thanks for reporting! I noticed that we don't bundle eventbridge (just cloudwatch-events). This should be included in the default runtime. Not all SDKs from v3 are bundled in the runtime at the moment to keep the size down for RTT during cold starts. We will build flavours of LLRT containing basic (current state), extended and full SDK.

ymwjbxxq commented 11 months ago

I think the SDK should be there, no flavours. Is there any link to see what is included?

richarddavison commented 11 months ago

I think the SDK should be there, no flavours. Is there any link to see what is included?

I will add to docs. For now, see here what's included: https://github.com/awslabs/llrt/blob/c88938895bbab05b81c96bbd7f45ddaf6f184547/build.mjs#L76

There is nothing (compatibility wise) preventing us from adding more in there. We have just included this based of popularity of packages.

ymwjbxxq commented 11 months ago

I think for serverless, you really need a few extra

It would be great if there was a way to configure the system to automatically pull in them, instead of manually adding them one by one.

richarddavison commented 11 months ago

Hi @ymwjbxxq. credential-providers packages does not seem to contain a AwsSigv4Signer. Where do you find this class? We have this package https://github.com/awslabs/smithy-typescript/tree/main/packages/signature-v4#smithysignature-v4 with SignatureV4

ymwjbxxq commented 11 months ago

Sorry for my mistake. I confused the lines when I saw the code.

import { AwsSigv4Signer } from "@opensearch-project/opensearch/aws";
import { fromEnv } from "@aws-sdk/credential-providers";

 return AwsSigv4Signer({
            region,
            getCredentials: fromEnv(),
        })
richarddavison commented 11 months ago

You should now have what you need: https://github.com/awslabs/llrt/releases/tag/v0.1.1-beta