I am following this tutorial for creating a sample workflow with AWS Step Functions and AWS Lambda. I have done everything as per the blog, but when I run it is showing failed status at the "Is Case Resolved" stage.
Screenshot: https://i.stack.imgur.com/ebmbb.png
I have done like below:
Step1: Created a role in AWS Management Console and copied the Role ARN value.
Step2: Created a new State Machine with the ASL code provided in the blog and added the Role ARN value.
Step3: Created all the 5 AWS Lambda Functions
Step4: Edited the state Machine and added the Resource value of the Lambda function.
Step5: Executed the workflow with the below code:
{
"inputCaseID": "001"
}
My ASL code in state machine:
{
"Comment": "A simple AWS Step Functions state machine that automates a call center support session.",
"StartAt": "Open Case",
"States": {
"Open Case": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-2:AccountId:function:OpenCaseFunction",
"Next": "Assign Case"
},
"Assign Case": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-2:AccountId:function:AssignCaseFunction",
"Next": "Work on Case"
},
"Work on Case": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-2:AccountId:function:WorkOnCaseFunction",
"Next": "Is Case Resolved"
},
"Is Case Resolved": {
"Type" : "Choice",
"Choices": [
{
"Variable": "$.Status",
"NumericEquals": 1,
"Next": "Close Case"
},
{
"Variable": "$.Status",
"NumericEquals": 0,
"Next": "Escalate Case"
}
]
},
"Close Case": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-2:AccountId:function:CloseCaseFunction",
"End": true
},
"Escalate Case": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-2:AccountId:function:EscalateCaseFunction",
"Next": "Fail"
},
"Fail": {
"Type": "Fail",
"Cause": "Engage Tier 2 Support." }
}
}
Error showing:
{
"error": "States.Runtime",
"cause": "An error occurred while executing the state 'Is Case Resolved' (entered at the event id #17). Invalid path '$.Status': The choice state's condition path references an invalid value."
}
OpenCaseFunction
exports.handler = (event, context, callback) => {
// Create a support case using the input as the case ID, then return a confirmation message
var myCaseID = event.inputCaseID;
var myMessage = "Case " + myCaseID + ": opened...";
var result = {Case: myCaseID, Message: myMessage};
callback(null, result);
};
AssignCaseFunction
exports.handler = (event, context, callback) => {
// Assign the support case and update the status message
var myCaseID = event.Case;
var myMessage = event.Message + "assigned...";
var result = {Case: myCaseID, Message: myMessage};
callback(null, result);
};
WorkOnCaseFunction
exports.handler = (event, context, callback) => {
// Generate a random number to determine whether the support case has been resolved, then return that value along with the updated message.
var min = 0;
var max = 1;
var myCaseStatus = Math.floor(Math.random() * (max - min + 1)) + min;
var myCaseID = event.Case;
var myMessage = event.Message;
if (myCaseStatus == 1) {
// Support case has been resolved
myMessage = myMessage + "resolved...";
} else if (myCaseStatus == 0) {
// Support case is still open
myMessage = myMessage + "unresolved...";
}
var result = {Case: myCaseID, Status : myCaseStatus, Message: myMessage};
callback(null, result);
};
EscalateCaseFunction
exports.handler = (event, context, callback) => {
// Escalate the support case
var myCaseID = event.Case;
var myCaseStatus = event.Status;
var myMessage = event.Message + "escalating.";
var result = {Case: myCaseID, Status : myCaseStatus, Message: myMessage};
callback(null, result);
};
CloseCaseFunction
exports.handler = (event, context, callback) => {
// Close the support case
var myCaseStatus = event.Status;
var myCaseID = event.Case;
var myMessage = event.Message + "closed.";
var result = {Case: myCaseID, Status : myCaseStatus, Message: myMessage};
callback(null, result);
};
What I am missing in this?



Always mask your Account ID. I am assuming this an Express Workflow, So you can share the logs of the state where it failed. Plus check the lambda namedfunction:WorkOnCaseFunctionwhat it is returning, because the further choice depends on the output of this function. - samtoddlerStatusfield inside the json. So check yourfunction:WorkOnCaseFunctionoutput and try to use the code provided in the guide. - samtoddler