Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AWS Step Functions State Machine for library loans
{
"Comment": "Library loans handler",
"StartAt": "StartLoan",
"States": {
"StartLoan": {
"Type": "Task",
"Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",
"Next": "CheckBookComeBack"
},
"CheckBookComeBack": {
"Type": "Parallel",
"End": true,
"Branches": [{
"StartAt": "GetComeBackLink",
"States": {
"GetComeBackLink": {
"Type": "Task",
"Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",
"End": true
}
}
}, {
"StartAt": "WaitBookComesBack",
"States": {
"WaitBookComesBack": {
"Type": "Wait",
"TimeoutSeconds": 10800,
"Next": "StopLoan",
"Catch": [{
"ErrorEquals": ["Timeout"],
"End": true
}]
},
"StopLoan": {
"Type": "Task",
"Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",
"End": true
}
}
}, {
"StartAt": "WaitReminder",
"States": {
"WaitReminder": {
"Type": "Wait",
"Seconds": 252000,
"Next": "CanRenew"
},
"CanRenew": {
"Type": "Choice",
"Choices": [{
"Variable": "$.canRenew",
"NumericEquals": 1,
"Next": "WaitRenew"
}],
"Default": "WaitDone"
},
"WaitRenew": {
"Type": "Parallel",
"Next": "IsRenewOrExpired",
"Branches": [{
"StartAt": "SendRenewLink",
"States": {
"SendRenewLink": {
"Type": "Task",
"Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",
"End": true
}
}
}, {
"StartAt": "WaitRenewAction",
"States": {
"WaitRenewAction": {
"Type": "Task",
"TimeoutSeconds": 10800,
"End": true,
"Catch": [{
"ErrorEquals": ["Timeout"],
"End": true
}]
}
}
}]
},
"IsRenewOrExpired": {
"Type": "Choice",
"Choices": [{
"Variable": "$.isRenew",
"NumericEquals": 1,
"Next": "WaitReminder"
}],
"Default": "LoanExpired"
},
"LoanExpired": {
"Type": "Parallel",
"End": true,
"Branches": [{
"StartAt": "SendDoneDeadlineLink",
"States": {
"SendDoneDeadlineLink": {
"Type": "Task",
"Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",
"End": true
}
}
}, {
"StartAt": "WaitDoneDeadline",
"States": {
"WaitDoneDeadline": {
"Type": "Task",
"End": true
}
}
}]
},
"WaitDone": {
"Type": "Parallel",
"End": true,
"Branches": [{
"StartAt": "SendDoneLink",
"States": {
"SendDoneLink": {
"Type": "Task",
"Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",
"End": true
}
}
}, {
"StartAt": "WaitDone",
"States": {
"WaitDone": {
"Type": "Task",
"TimeoutSeconds": 10800,
"Next": "Returned",
"Catch": [{
"ErrorEquals": ["Timeout"],
"Next": "SendDeadlineEmail"
}]
},
"Returned": {
"Type": "Pass",
"End": true
},
"SendDeadlineEmail": {
"Type": "Parallel",
"End": true,
"Branches": [{
"StartAt": "SendDoneDeadlineLink",
"States": {
"SendDoneDeadlineLink": {
"Type": "Task",
"Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",
"End": true
}
}
}, {
"StartAt": "WaitDoneDeadline",
"States": {
"WaitDoneDeadline": {
"Type": "Task",
"End": true
}
}
}]
}
}
}]
}
}
}]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.