我有一个像下面这样的状态机。如果它有 1000 条消息要通知,它会将通知分散到 15 分钟内。
现在,如果我有一个具有完全相同状态流但具有自己的一组 lambda 的 TwoHourStateMachine,我将如何重用这些状态,以便不再重复定义?
状态机:
FifteenMinuteStateMachine:
Type: "AWS::StepFunctions::StateMachine"
Properties:
StateMachineName: "FifteenMinuteStateMachine"
DefinitionString:
Fn::Sub: |-
{
"Comment": "A 15 minute state machine",
"StartAt": "Initialize",
"TimeoutSeconds": 900,
"States": {
"Initialize" : {
"Type": "Task",
"Resource": "${InitFifteenMinuteLambda.Arn}",
"TimeoutSeconds": 15,
"Retry": [ {
"ErrorEquals": [ "States.Timeout", "Lambda.Unknown" ],
"IntervalSeconds": 2,
"MaxAttempts": 3,
"BackoffRate": 2
} ],
"Catch": [{
"ErrorEquals": ["States.ALL"],
"ResultPath": "$.errorOutput",
"Next": "Update Status"
}],
"Next": "Notification Job"
},
"Notification Job" : {
"Type": "Task",
"Resource": "${NotificationFifteenMinuteLambda.Arn}",
"TimeoutSeconds": 15,
"Retry": [ {
"ErrorEquals": [ "States.Timeout", "Lambda.Unknown" ],
"IntervalSeconds": 2,
"MaxAttempts": 3,
"BackoffRate": 2
} ],
"Catch": [{
"ErrorEquals": ["States.ALL"],
"ResultPath": "$.errorOutput",
"Next": "Update Status"
}],
"Next": "All Notifications sent?"
},
"All Notifications sent?": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.status",
"StringEquals": "IN_PROGRESS",
"Next": "Wait X Seconds"
},
{
"Variable": "$.status",
"StringEquals": "SUCCEEDED",
"Next": "Update Status"
}
],
"Default": "Wait X Seconds"
},
"Wait X Seconds": {
"Type": "Wait",
"SecondsPath": "$.notificationIntervalInSeconds",
"Next": "Notification Job"
},
"Update Status": {
"Type": "Task",
"Resource": "${StatusUpdateFifteenMinuteLambda.Arn}",
"TimeoutSeconds": 15,
"End": true
}
}
}
RoleArn:
Fn::GetAtt: [ StepFunctionExecutionRole, Arn ]