Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ymwjbxxq opened this issue Oct 28, 2023 · 7 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@ymwjbxxq
Copy link
Collaborator

ymwjbxxq commented Oct 28, 2023

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 richarddavison added enhancement New feature or request bug Something isn't working labels Oct 29, 2023
@richarddavison
Copy link
Contributor

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
Copy link
Collaborator Author

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

@richarddavison
Copy link
Contributor

richarddavison commented Oct 29, 2023

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:

llrt/build.mjs

Line 76 in c889388

const SDK_DATA = {

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

@ymwjbxxq
Copy link
Collaborator Author

I think for serverless, you really need a few extra

  • @aws-sdk/client-eventbridge (is everywhere nowadays)
  • @aws-sdk/util-dynamodb -> for unmarshall items
  • @aws-sdk/client-sfn
  • @aws-sdk/credential-providers -> for AwsSigv4Signer
  • @aws-sdk/client-xray

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
Copy link
Contributor

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
Copy link
Collaborator Author

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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants