More Info:

Your AWS Lambda Functions should have default timeout set in order to achieve greater relaibility and availability.

Risk Level

Low

Address

Reliability, Security

Compliance Standards

CBP

Triage and Remediation

Remediation

Using Console

Sure, here are the step-by-step instructions to remediate the misconfiguration of Lambda Functions not having a default timeout set in AWS:
  1. Open the AWS Management Console and navigate to the Lambda service.
  2. Click on the name of the Lambda function that needs to be remediated.
  3. Scroll down to the Basic settings section and click on the Edit button next to the Timeout value.
  4. Set an appropriate timeout value for the function, keeping in mind the function’s execution time and any dependencies it may have.
  5. Click on the Save button to apply the changes.
That’s it! The Lambda function now has a default timeout set, which helps ensure that it doesn’t run indefinitely and incur unnecessary costs.

To remediate the misconfiguration “Lambda Functions Should Have Default Timeout Set” for AWS using AWS CLI, follow these steps:
  1. Open the AWS CLI on your computer.
  2. Run the following command to get a list of all the Lambda functions in your AWS account:
aws lambda list-functions
  1. Identify the Lambda function that does not have a default timeout set.
  2. Run the following command to set a default timeout for the identified Lambda function:
aws lambda update-function-configuration --function-name <function-name> --timeout <timeout-value>
Replace <function-name> with the name of the identified Lambda function and <timeout-value> with the timeout value you want to set in seconds. For example, if you want to set the timeout to 5 minutes, you can set the <timeout-value> to 300.
  1. Verify that the default timeout has been set for the Lambda function by running the following command:
aws lambda get-function-configuration --function-name <function-name>
Replace <function-name> with the name of the identified Lambda function. The output should include the timeout value you set in the previous step.
  1. Repeat steps 3-5 for any other Lambda functions that do not have a default timeout set.
By following these steps, you have successfully remediated the misconfiguration “Lambda Functions Should Have Default Timeout Set” for AWS using AWS CLI.
Sure, here are the step-by-step instructions to remediate the misconfiguration “Lambda Functions Should Have Default Timeout Set” for AWS using Python:
  1. Open the AWS Management Console and navigate to the AWS Lambda service page.
  2. Select the Lambda function for which you want to set the default timeout.
  3. Click on the “Configuration” tab.
  4. Scroll down to the “General configuration” section.
  5. Under “Basic settings”, click on the “Edit” button.
  6. Set the “Timeout” value to a default value of your choice. For example, you can set it to 30 seconds.
  7. Click on the “Save” button to save the changes.
Here is the Python code to set the default timeout for an AWS Lambda function:
import boto3

# Replace 'function_name' with the name of the Lambda function for which you want to set the default timeout
function_name = '<function_name>'

# Replace 'timeout' with the default timeout value in seconds
timeout = 30

# Create a Lambda client
lambda_client = boto3.client('lambda')

# Update the function configuration
response = lambda_client.update_function_configuration(
    FunctionName=function_name,
    Timeout=timeout
)

# Print the response
print(response)
Make sure you have the AWS SDK for Python (Boto3) installed before running this code. You can install it using the following command:
pip install boto3
That’s it! This code will set the default timeout for the specified Lambda function.

Additional Reading: