I am trying to add addCatch to a fargate task running inside step function using aws cdk Typescript Custom State.
new CustomState(this, "Failed", {
stateJson: {
Type: "Fail",
},
});
const stateJson = {
Type: 'Task',
Resource: 'arn:aws:states:::ecs:runTask.sync',
Retry: [
{
ErrorEquals: ["ECS.AmazonECSException"],
IntervalSeconds: 2,
MaxAttempts: 6,
BackoffRate: 2,
}
],
Catch: [
{
ErrorEquals: ["States.All"],
Next: "$.Failed",
ResultPath: "$.error",
},
],
Parameters: {
LaunchType: "FARGATE",
Cluster: clusterName,
TaskDefinition: TaskDefinition,
},
ResultPath: '$.FargateOutput',
};
const custom = new sfn.CustomState(this, 'my custom task', {
stateJson,
});
const chain = sfn.Chain.start(custom)
.next(finalStatus);
const sm = new sfn.StateMachine(this, 'StateMachine', {
definition: chain,
timeout: Duration.seconds(30),
});
But during deployment I am getting error Invalid State Machine Definition: 'MISSING_TRANSITION_TARGET: Missing 'Next' target: $.Failed