question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't increase lambda timeout on custom resource lambda

See original GitHub issue
  • I’m submitting a …

    • 🪲 bug report
    • 🚀 feature request
    • 📚 construct library gap
    • ☎️ security issue or vulnerability => Please see policy
    • ❓ support request => Please see note at the top of this template.
  • What is the current behavior? If the current behavior is a 🪲bug🪲: Please provide the steps to reproduce The current timeout for custom resource lambda is set to 3 seconds. My lambda for the custom resource is taking a bit longer than 3 seconds to complete.

  • What is the expected behavior (or behavior of feature suggested)? I would like to be able to configure the lambda timeout for custom resource, or see an increase in the default timeout value.

  • What is the motivation / use case for changing the behavior or adding this feature? To support lambdas that might run into timeout issue. If the timeout happens 3 times, which it did for me, you will end up with a stack that is stuck for an hour.

  • Please tell us about your environment:

    • CDK CLI Version: 0.37.0
    • Module Version: 0.37.0
    • OS: [OSX Mojave]
    • Language: [TypeScript]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)

I managed to overwrite the value with:

    const userPoolDomainNameLambda = (userPoolDomainNameCustomResource.node
      .findAll(ConstructOrder.PREORDER)
      .find(construct => {
        return construct instanceof lambda.SingletonFunction;
      }) as lambda.SingletonFunction)["lambdaFunction"].node.children.find((child: any) => {
      return child instanceof lambda.CfnFunction;
    }) as lambda.CfnFunction;

    userPoolDomainNameLambda.addPropertyOverride("Timeout", "300");

Now it is working for me. The execution time of the lambda ended up being 3400ms.

Cheers!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dveijckcommented, Oct 21, 2019

@SomayaB I hope I can help out clarifying this issue a bit.

I had the exact same situation where I needed to provide a custom Cognito UserPool Domain through CDK. I created an AwsCustomResource just like @abelmokadem to invoke the CognitoIdentityServiceProvider#createUserPoolDomain API (CloudFormation has only provided direct support for this setup somewhere in the last two weeks, so the actual example is not relevant anymore, but this issue still is!).

I also experienced a Lambda execution time-out on this AWS API call. To me it is entirely unclear why this API call takes longer than 3 seconds to complete as there is no information available (either the Lambda function just get killed because of the execution time-out and that is what you see in the logs or it just works if the execution time-out is extended long enough), but I personally see no reason why an API call shouldn’t take any longer than 3 seconds.

The case @abelmokadem makes is that since AwsCustomResource relies on a Lambda function to create the custom resource, it would be nice to at least provide the option to set the time-out property for this Lambda. Regardless of the short response times AWS tries to achieve for its API’s, calls for custom resources just might take longer than expected for whatever reason (as in @abelmokadem’s and my situation). The workaround @abelmokadem suggests works fine (it solved my issue as well), however as you can see, it requires the users to go through quite some ‘hassle’ to get a hold on the CfnFunction to be able to override the execution time-out.

Hope it helps in understanding this issue.

1reaction
robertdcommented, Jul 10, 2019

@abelmokadem Just like @NGL321 suggested… cdk switched form number to cdk.Duration recently (#2857). I had the same issue and had to update all my cdk apps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Learn best practices for implementing AWS Lambda-backed ...
Build your custom resources to report, log, and handle failure · Set reasonable timeout periods, and report when they're about to be exceeded....
Read more >
Change the Default TimeOut of AWS Custom Resource
Can we change the default timeout of AWS CustomResource, as its default timeout is 1 hour and the job that will return an...
Read more >
How to overcome the maximum timeout limit in AWS Lambda
As a best practice, we should set the timeout value based on our expected execution time to prevent our Lambda functions from running...
Read more >
AWS Lambda Timeout Best Practices - Lumigo
Use short timeout limits for event sources – set timeout to 3-6 seconds for API calls. · Monitor Lambda function timeouts · Use...
Read more >
How can I avoid waiting for one hour if my custom resource ...
1.- Catch and handle the exception (lambda execution error) to send the FAILED status signal back to CloudFormation before the lambda ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found