Table of Contents
Question
A developer creates an AWS Lambda function that runs when an object is put into an Amazon S3 bucket. The function reformats the object and places the object back into the S3 bucket. During testing, the developer notices a recursive invocation loop. The developer asks a SysOps administrator to immediately stop the recursive invocations. What should the SysOps administrator do to stop the loop without errors?
A. Delete all the objects from the S3 bucket.
B. Set the function’s reserved concurrency to 0.
C. Update the S3 bucket policy to deny access for the function.
D. Publish a new version of the function.
Answer
B. Set the function’s reserved concurrency to 0.
Explanation
The correct answer to the question is B. Set the function’s reserved concurrency to 0.
Explanation:
A recursive invocation loop is a situation where a Lambda function triggers itself repeatedly, either directly or indirectly, causing an infinite loop of executions. This can result in high costs, performance issues, and resource exhaustion. A common cause of recursive invocation loops is when a Lambda function modifies an S3 object that triggers the same function again.
To stop the recursive invocations, the SysOps administrator needs to prevent the Lambda function from running. One way to do this is to set the function’s reserved concurrency to 0. Reserved concurrency is a setting that limits the number of concurrent executions that a function can have at any given time. By setting it to 0, the SysOps administrator can effectively disable the function and stop the loop.
To set the function’s reserved concurrency to 0, the SysOps administrator can use the AWS Management Console, the AWS CLI, or the AWS SDK. For example, using the AWS CLI, the SysOps administrator can run the following command:
aws lambda put-function-concurrency –function-name FunctionName –reserved-concurrent-executions 0
This command will set the reserved concurrency of the function named FunctionName to 0. The SysOps administrator can also use the AWS Management Console to do this by following these steps:
- Open the AWS Management Console and go to the Lambda service.
- Select the function that is causing the recursive invocation loop.
- In the Configuration tab, under General configuration, click on Edit.
- In the Concurrency section, select Reserve concurrency and enter 0 in the box.
- Click on Save.
After setting the function’s reserved concurrency to 0, the SysOps administrator can check the CloudWatch metrics and logs to verify that the recursive invocations have stopped. The SysOps administrator can also troubleshoot and fix the root cause of the loop, such as adding a condition or filter to prevent the function from triggering itself again. For more details, you can refer to this article.
Therefore, option B is correct. Options A, C, and D are incorrect because they are not effective or efficient ways to stop the recursive invocations. Option A will delete all the data from the S3 bucket, which may not be desirable or necessary. Option C will deny access for the function to access the S3 bucket, which may cause errors or failures in other functions or applications that depend on it. Option D will publish a new version of the function, but it will not stop the existing version from running unless it is deleted or disabled.
Reference
- Lambda recursive loop detection – AWS Lambda (amazon.com)
- Detecting and stopping recursive loops in AWS Lambda functions | AWS Compute Blog (amazon.com)
- amazon web services – Prevent accidental infinite loop in Lambda with API Gateway – Stack Overflow
Amazon AWS Certified SysOps Administrator – Associate certification exam practice question and answer (Q&A) dump with detail explanation and reference available free, helpful to pass the Amazon AWS Certified SysOps Administrator – Associate exam and earn Amazon AWS Certified SysOps Administrator – Associate certification.