AWS Certified Developer – Associate (DVA-C02) — Question 318
A developer is building a serverless application on AWS for a workflow that processes high volumes of data. In the workflow, an AWS Step Functions state machine invokes several AWS Lambda functions.
One of the Lambda functions occasionally fails because of timeout errors during periods of high demand. The developer must ensure that the workflow automatically retries the failed function invocation if a timeout error occurs.
Which solution will meet this requirement?
Answer options
- A. Add a Retry field in the Step Functions state machine definition. Configure the state machine with the maximum number of retry attempts and the timeout error type to retry on.
- B. Add a Timeout field in the Step Functions state machine definition. Configure the state machine with the maximum number of retry attempts.
- C. Add a Fail state to the Step Functions state machine definition. Configure the state machine with the maximum number of retry attempts.
- D. Update the Step Functions state machine to pass the invocation request to an Amazon Simple Notification Service (Amazon SNS) topic. Subscribe a Lambda function to the SNS topic. Configure the Lambda function with the maximum number of retry attempts for a timeout error type.
Correct answer: A
Explanation
AWS Step Functions allows developers to handle errors and retries directly within the state machine definition using the 'Retry' field, where specific error types like 'States.Timeout' can be targeted with custom retry behaviors. Option B is incorrect because the Timeout field only sets maximum execution duration, not retry behavior, while Option C's Fail state terminates execution with an error instead of retrying. Option D is incorrect because introducing Amazon SNS adds unnecessary architectural complexity and does not natively manage the state machine's retry logic for the Lambda function.