Question #1043
A developer is designing an AWS Step Functions state machine to manage a data validation process. The state machine must pause until a validation record is added to an Amazon DynamoDB table by an external service. Once the record is present, the state machine should proceed with the next steps.
Which solution fulfills this requirement?
Modify the state machine to include a DynamoDB GetItem task that checks for the validation record. If the record exists, proceed; otherwise, wait for 10 minutes and check again.
Set up a DynamoDB Stream to trigger an AWS Lambda function when a new record is added. The Lambda function invokes the RedriveExecution API for the paused state machine execution to resume.
Configure an Amazon EventBridge rule to detect the DynamoDB record addition and trigger a Lambda function that starts a new state machine execution.
Use a Lambda function within the state machine to poll the DynamoDB table continuously until the validation record is found, then return success. If the Lambda times out, fail the state machine.
Explanation
Option B is correct because it uses DynamoDB Streams to detect the new validation record and triggers a Lambda function. This Lambda then resumes the paused state machine execution via the RedriveExecution API, ensuring the process continues only when the record is available. This approach is event-driven, efficient, and avoids polling or timeouts.
Other options are incorrect:
- A: Polling with GetItem introduces delays and unnecessary costs.
- C: EventBridge starts a new execution instead of resuming the existing one.
- D: Continuous polling in Lambda risks timeouts and inefficiency.
Key Points:
1. Use DynamoDB Streams for real-time event detection.
2. Lambda can resume paused Step Functions executions via APIs like RedriveExecution.
3. Avoid polling to reduce costs and improve responsiveness.
Answer
The correct answer is: B