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

Unable to use cloudfront origin-response eventType if memorySize or timeout exceeds 128 and 5 #6913

Closed
winstonwp opened this issue Nov 1, 2019 · 1 comment · Fixed by #6922
Closed

Comments

@winstonwp
Copy link
Contributor

@winstonwp winstonwp commented Nov 1, 2019

Bug Report

Description

What did you do?

In setting up an image resize lambda function in the origin-request of a cloudformation distribution with AWS.Rekognition and sharp. This function consumes more than 128Mb and takes more than 5 seconds on every case.
My serverless.yml file looks something like this:

...
functions:
  originResponseFunction:
    handler: originResponseFunction/index.handler
    timeout: 30
    memorySize: 896
    events:
      - cloudFront:
          eventType: origin-response
          origin: ${self:custom.origins.${self:provider.stage}}
...

What happened?

When I run the command sls deploy I get the follwing error message:

  Error --------------------------------------------------
 
  Error: "originResponseFunction" memorySize is greater than 128 which is not supported by Lambda@Edge functions
      at serverless.service.getAllFunctions.forEach.functionName (/home/winstonwp/.nvm/versions/node/v10.16.0/lib/node_modules/serverless/lib/plugins/aws/package/compile/events/cloudFront/index.js:46:17)
      at Array.forEach (<anonymous>)
      at AwsCompileCloudFrontEvents.validate (/home/winstonwp/.nvm/versions/node/v10.16.0/lib/node_modules/serverless/lib/plugins/aws/package/compile/events/cloudFront/index.js:42:47)
      at BbPromise.reduce (/home/winstonwp/.nvm/versions/node/v10.16.0/lib/node_modules/serverless/lib/classes/PluginManager.js:505:55)
      at tryCatcher (/home/winstonwp/.nvm/versions/node/v10.16.0/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
      at Object.gotValue (/home/winstonwp/.nvm/versions/node/v10.16.0/lib/node_modules/serverless/node_modules/bluebird/js/release/reduce.js:168:18)
      at Object.gotAccum (/home/winstonwp/.nvm/versions/node/v10.16.0/lib/node_modules/serverless/node_modules/bluebird/js/release/reduce.js:155:25)
      at Object.tryCatcher (/home/winstonwp/.nvm/versions/node/v10.16.0/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/home/winstonwp/.nvm/versions/node/v10.16.0/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/home/winstonwp/.nvm/versions/node/v10.16.0/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromise0 (/home/winstonwp/.nvm/versions/node/v10.16.0/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:649:10)
      at Promise._settlePromises (/home/winstonwp/.nvm/versions/node/v10.16.0/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:729:18)
      at _drainQueueStep (/home/winstonwp/.nvm/versions/node/v10.16.0/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:93:12)
      at _drainQueue (/home/winstonwp/.nvm/versions/node/v10.16.0/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/home/winstonwp/.nvm/versions/node/v10.16.0/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (/home/winstonwp/.nvm/versions/node/v10.16.0/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:15:14)
      at runCallback (timers.js:705:18)
      at tryOnImmediate (timers.js:676:5)
      at processImmediate (timers.js:658:5)
      at process.topLevelDomainCallback (domain.js:126:23)

What should've happened?

For the time being I'm setting the lambda function manually in my AWS CloudFront Distribution, and I'm able to configure the originResponseFunction with a memorySize of 896Mb and 30s timeout.
Running sls deploy should allow me to deploy an eventType: origin-response lambda function with greater memorySize and timeout values.

I've identified a possible solution for this issue and will be happy to submit a Pull Request, but I'm not certain of what approach should I use, a disableValidation flag or an exception for eventType: origin-response when running the validate function.

@winstonwp

This comment has been minimized.

Copy link
Contributor Author

@winstonwp winstonwp commented Nov 1, 2019

I followed this example from AWS blog to write the image resize function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.