Slide 9
Slide 9 text
© 2022, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CDK Step Functions コンストラクトの利⽤
CDK V1の場合︓
• @aws-cdk/aws-stepfunctions パッ
ケージは、ワークフローを構築する
ためのコンストラクト
• @aws-cdk/aws-stepfunctions-
tasksパッケージは、他のAWSサービ
スを呼び出すために使⽤されるクラ
ス
CDK V2の場合︓
• aws-cdk-lib/aws_stepfunctions_tasks
• aws-cdk-lib/aws_stepfunctions
(snip)
const getStatus = new tasks.LambdaInvoke(this, 'Get Job Status', {
lambdaFunction: getStatusLambda,
// Pass just the field named "guid" into the Lambda, put the
// Lambda's result in a field called "status" in the response
inputPath: '$.guid',
outputPath: '$.Payload',
});
const definition = submitJob
.next(waitX)
.next(getStatus)
.next(new sfn.Choice(this, 'Job Complete?')
// Look at the "status" field
.when(sfn.Condition.stringEquals('$.status', 'FAILED'), jobFailed)
.when(sfn.Condition.stringEquals('$.status', 'SUCCEEDED'), finalStatus)
.otherwise(waitX));
new sfn.StateMachine(this, 'StateMachine', {
definition,
timeout: Duration.minutes(5),
});