Question #843
A developer is using AWS Step Functions to orchestrate a workflow where each step is defined as an Amazon SNS publish task. The developer observes that state machine executions fail in the PublishNotification task with either an AccessDeniedException error or a ThrottlingException error.
The developer wants the state machine to halt execution immediately when encountering an AccessDeniedException error. For ThrottlingException errors, the state machine should retry the PublishNotification task once after a 15-second interval. If the retry fails, the execution should terminate.
How can the developer implement this error-handling logic while minimizing complexity in the state machine definition?
Add a catcher to the PublishNotification task for AccessDeniedException to stop execution. Add another catcher for ThrottlingException with a 15-second Delay task and route back to PublishNotification.
Create a retrier for the PublishNotification task with error type AccessDeniedException and max attempts 0. Add a separate retrier for ThrottlingException with max attempts 1 and interval 15 seconds.
Add a retrier to the PublishNotification task configured for ThrottlingException with interval=15 and max attempts=1. Add a catcher for AccessDeniedException to stop execution.
Duplicate the PublishNotification task as RetryPublish. Add a catcher to the original task for ThrottlingException pointing to RetryPublish, and a catcher for AccessDeniedException to stop execution.
Explanation
Answer C is correct because:
1. Retrier for ThrottlingException: Configures a retry policy (max_attempts=1, interval=15) to handle transient throttling errors, aligning with the requirement.
2. Catcher for AccessDeniedException: Directly stops execution using a catcher (e.g., transitioning to a Fail state), ensuring immediate termination for non-retryable errors.
Other options are incorrect because:
- A: Uses catchers with Delay tasks, adding unnecessary states and complexity.
- B: Retriers cannot halt execution; they only control retries. AccessDenied requires immediate termination, which retriers alone cannot achieve.
- D: Duplicates tasks, increasing complexity.
Key Points:
- Use retriers for transient errors requiring retries.
- Use catchers to route to error-handling states for non-retryable errors.
- Avoid duplicating tasks or adding extra states to minimize complexity.
Answer
The correct answer is: C