Change the Default TimeOut of AWS Custom Resource
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
AWS CloudFormation is a powerful tool for automating the deployment of infrastructure as code. A unique feature in CloudFormation is Custom Resources, which allow you to execute custom logic during stack creation, update, and deletion operations. However, a significant aspect to manage with Custom Resources is their timeout settings, as they may need more time for operations compared to standard resources. This article explores how to adjust the default timeout setting for AWS Custom Resources, offering ways to ensure your resources are provisioned effectively.
Understanding AWS Custom Resources
Custom Resources in AWS CloudFormation allow you to execute arbitrary Amazon Web Services (AWS) Lambda functions or send properties to an Amazon Simple Queue Service (SQS) queue. These resources are essential for processes that do not come out-of-the-box with AWS CloudFormation, thereby extending its functionality.
How Custom Resources Work
When you define a Custom Resource in AWS CloudFormation, it triggers an AWS Lambda function which is expected to report back success or failure. This communication is usually done through a pre-signed Amazon S3 URL. The resource must report its status back to AWS CloudFormation within the timeout period; otherwise, the stack operation will fail.
The Default Timeout Issue
The default timeout for AWS Custom Resources is 60 minutes. This timeout duration might be insufficient for operations that involve complex network settings, dependencies on external systems, or intensive computations. Therefore, there is a need to tweak these defaults to suit your specific requirements.
Changing the Timeout for AWS Custom Resources
The CloudFormation Custom Resources themselves do not provide a direct parameter to adjust the timeout setting. However, you can manage this via the AWS Lambda function configuration that handles your Custom Resource logic.
Adjusting AWS Lambda Timeout
When you create an AWS Lambda function, one of the critical configuration settings you need to specify is the function's timeout:
- Using AWS Console:
Navigate to the Lambda service in the AWS Management Console. Select the function associated with your Custom Resource. Inside the "Configuration" tab, find the "General configuration" section and click on "Edit" to change the Timeout setting. AWS allows a maximum timeout of up to 15 minutes for Lambda functions. - Using AWS CLI:

