CodexBloom - Programming Q&A Platform

AWS Step Functions: scenarios Handling with Parallel States and Retry Policy

👀 Views: 1717 💬 Answers: 1 📅 Created: 2025-06-12
aws step-functions lambda JSON

I'm relatively new to this, so bear with me. I'm working on an AWS Step Functions state machine that orchestrates multiple Lambda functions running in parallel. The goal is to implement a retry policy for each Lambda function in case of failure, but I'm working with issues with how the behavior handling works when using a `Parallel` state. My state machine definition looks like this: ```json { "Comment": "A Parallel State example that retries on failure", "StartAt": "ProcessTasks", "States": { "ProcessTasks": { "Type": "Parallel", "Branches": [ { "StartAt": "Task1", "States": { "Task1": { "Type": "Task", "Resource": "arn:aws:lambda:us-east-1:123456789012:function:Task1", "Retry": [ { "ErrorEquals": ["Lambda.Unknown"], "IntervalSeconds": 2, "MaxAttempts": 3, "BackoffRate": 2.0 } ], "End": true } } }, { "StartAt": "Task2", "States": { "Task2": { "Type": "Task", "Resource": "arn:aws:lambda:us-east-1:123456789012:function:Task2", "Retry": [ { "ErrorEquals": ["Lambda.Unknown"], "IntervalSeconds": 2, "MaxAttempts": 2, "BackoffRate": 1.5 } ], "End": true } } } ], "ResultPath": null, "End": true } } } ``` I've set up individual retry policies for each task, but I'm finding that when `Task1` fails, it retries as expected. However, I get a strange behavior message in the execution history: `"Execution failed with behavior: Task2 failed with behavior: 'Lambda.Unknown'"` when `Task2` is invoked. I would have thought it would just retry that task instead of failing the entire parallel branch. I've also tried modifying the `ResultPath` but it didn't seem to fix the scenario. Shouldn’t each branch's behavior handling work independently? Additionally, I’ve verified that the Lambda functions are set up correctly and are returning the expected errors. Am I missing something in the configuration of the `Parallel` state or the way behavior handling is set up? Any guidance would be really helpful. My team is using Json for this REST API. Any suggestions would be helpful. Any pointers in the right direction?