up: Add timeout config option when invoking lambda directly.

Prerequisites

  • I am running the latest version. (up upgrade)
  • I searched to see if the issue already exists.
  • I inspected the verbose debug output with the -v, --verbose flag.
  • Are you an Up Pro subscriber?

Description

I’d like to call my application (lambda function) directly with cloudwatch for daily batch work which takes longer than 30 seconds. I’ve increase the timeout on my lambda function, but there is still a timeout in up which I can’t modify. I did find a similar request https://github.com/apex/up/issues/751. I’m asking for the something similar with another reason. Please give us a way to increase the timeout when calling lambda directly and not through api gateway.

I understand as a workaround I can deploy “background work” as a separated function and call it, but up is already configured with all my CI pipelines and environment variables and I really like using up! This would be an amazing feature for me.

Steps to Reproduce

Deploy an application which takes longer than 15 seconds to complete:

const Koa = require("koa");
const app = module.exports = new Koa();

app.use(async function(ctx) {
  await new Promise((resolve) => setTimeout(resolve, 60000));
  console.log("Blocking log");
  ctx.body = "Hello World";
});

if (!module.parent) app.listen(process.env.PORT || 3000);

Run the following commands:

up
aws lambda update-function-configuration --function-name apex-timeout --timeout 100 --region eu-west-1
aws lambda invoke --function-name apex-timeout --cli-binary-format raw-in-base64-out --payload '{ "path": "/" }' out --log-type Tail --region eu-west-1 --query 'LogResult' --output text |  base64 -d

Output:

.
.
.
2020/08/31 11:21:43 http: proxy error: net/http: timeout awaiting response headers
{"fields":{"app":"apex-timeout","duration":15021,"id":"","ip":"","method":"GET","path":"/","plugin":"logs","query":"","region":"eu-west-1","size":0,"stage":"staging","status":502,"version":"$LATEST"},"level":"error","timestamp":"2020-08-31T11:21:43.092673704Z","message":"response"}
END RequestId: ***
REPORT RequestId: ***	Duration: 16129.38 ms	Billed Duration: 16200 ms	Memory Size: 512 MB	Max Memory Used: 98 MB	Init Duration: 182.57 ms	

When I try to increase the timeout to 100 using .proxy.timeout:

Error: initializing: reading config: validating: .proxy: .timeout: should be <= 25

up.json for reference:

{
  "name": "apex-timeout",
  "regions": [
    "eu-west-1"
  ]
}

Love Up?

Please consider signing up for Up Pro (https://up.docs.apex.sh/#guides.subscribing_to_up_pro) or donating via https://opencollective.com/apex-up/donate.

Slack

Join us on Slack https://chat.apex.sh/

EDIT: updated aws cli command to work with cli version 2

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Just tested it and it works perfectly. Thanks!