serverless-bundle icon indicating copy to clipboard operation
serverless-bundle copied to clipboard

Use newer version of aws-sdk than the one supported by Lambda

Open jliburd-nsi opened this issue 6 years ago • 7 comments

I am trying to use the EventBridge client from aws-sdk. Lambda does not support the latest version of the SDK that has the EventBridge code. I included the latest version of aws-sdk in my package dependencies but when the code is bundled by serverless-bundle and deployed, I get an error stating "AWS.EventBridge is not a constructor". Am i doing something wrong? How do I include my own version of aws-sdk in lambda.

My code is:

`const AWS = require("aws-sdk"); const eventBridge = new AWS.EventBridge({ region: "us-east-1", apiVersion: "2015-10-07" });

..............`

jliburd-nsi avatar Oct 17 '19 01:10 jliburd-nsi

Yeah so serverless-bundle explicitly excludes the aws-sdk that you include and uses the one in Lambda. So this error makes sense. Usually Lambda adds support fairly quickly for new SDKs.

jayair avatar Nov 02 '19 21:11 jayair

Ok. Thanks for the info.

jliburd-nsi avatar Nov 03 '19 02:11 jliburd-nsi

It would be great if there was an option to explicitly include my local aws-sdk as an external module, and include it in the bundle; I don't want to wait for AWS to decide when to update the SDK in the runtime, and I want to make sure that the SDK version I'm running in the Lambda environment is the same version I'm running locally.

hotgazpacho avatar Dec 06 '19 14:12 hotgazpacho

Hmm that's interesting. We didn't have plans for this. But I'll reopen the issue and if other folks are running into this then we'll look into it.

jayair avatar Jan 02 '20 19:01 jayair

@jayair It would be awesome to have a general support for configuring webpack excludes. I'm using puppeteer in a layer, and had found a trail through to a config like this:

custom:
  webpack:
    includeModules:
      forceExclude:
        - chrome-aws-lambda

(found by looking at serverless-webpack linked from the readme) - but that gives an error that the configs conflict — and I don't see another option)

Piggybacking on this issue as it seems to be semi related?

nagey avatar Jan 14 '20 14:01 nagey

Oh that's interesting. Can you share more details on what you are trying to do? Possibly with a sample repo that I could try out?

jayair avatar Jan 26 '20 17:01 jayair

Usually Lambda adds support fairly quickly for new SDKs.

Not quickly enough. It is At least 80 days old at this very moment (can't use SNS.publishBatch yet)

carvantes avatar Feb 10 '22 19:02 carvantes