AnomalyInnovations / serverless-bundle

Optimized packages for ES6 and TypeScript Node.js Lambda functions without any configuration.
https://serverless-stack.com/chapters/package-lambdas-with-serverless-bundle.html
MIT License
536 stars 157 forks source link

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

Open jliburd-nsi opened 5 years ago

jliburd-nsi commented 5 years ago

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" });

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

jayair commented 5 years ago

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.

jliburd-nsi commented 5 years ago

Ok. Thanks for the info.

hotgazpacho commented 4 years ago

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.

jayair commented 4 years ago

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.

nagey commented 4 years ago

@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?

jayair commented 4 years ago

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?

carvantes commented 2 years ago

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)