Skip to content

Instantly share code, notes, and snippets.

@masaedw
Created June 11, 2020 07:23
Show Gist options
  • Save masaedw/72f7482bd35ecfca3586d12b10350fc2 to your computer and use it in GitHub Desktop.
Save masaedw/72f7482bd35ecfca3586d12b10350fc2 to your computer and use it in GitHub Desktop.
State 'task3' already has a next state
import cdk = require("@aws-cdk/core");
import sfn = require("@aws-cdk/aws-stepfunctions");
import { Duration } from "@aws-cdk/core";
export class SampleStack extends cdk.Stack {
constructor(app: cdk.App, id: string, props?: cdk.StackProps) {
super(app, id, props);
const task1 = new sfn.Wait(this, "task1", {
time: sfn.WaitTime.duration(Duration.minutes(1)),
});
const task2 = new sfn.Wait(this, "task2", {
time: sfn.WaitTime.duration(Duration.seconds(60 / 4)),
});
const task3 = new sfn.Wait(this, "task3", {
time: sfn.WaitTime.duration(Duration.seconds(60 / 4)),
});
const task4 = new sfn.Choice(this, "task4");
const cond1 = sfn.Condition.booleanEquals("$.hoge", true);
const cond2 = sfn.Condition.booleanEquals("$.fuga", true);
const task5 = new sfn.Wait(this, "task5", {
time: sfn.WaitTime.duration(Duration.seconds(5)),
});
const task6 = new sfn.Wait(this, "task6", {
time: sfn.WaitTime.duration(Duration.seconds(5)),
});
const task7 = new sfn.Wait(this, "task7", {
time: sfn.WaitTime.duration(Duration.seconds(5)),
});
new sfn.StateMachine(this, "machine1", {
definition: task1
.next(task2)
.next(task3)
.next(
task4
.when(cond1, task2)
.when(cond2, task5)
.otherwise(task6)
.afterwards()
)
.next(task7),
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment