Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
scope: cdk.Construct,
compileReport: lambda.Function,
reviewer: lambda.Function,
publishReport: lambda.Function,
errorHandler: lambda.Function,
delay?: cdk.Duration,
sfnRole?: iam.IRole
): sfn.StateMachine {
const waitTime = delay || cdk.Duration.minutes(10);
const invokeErrorHandler = new tasks.LambdaInvoke(
scope,
"InvokeErrorHandler",
{ lambdaFunction: errorHandler }
);
const condFailed = sfn.Condition.stringEquals("$.status", "FAILED");
const condSucceeded = sfn.Condition.stringEquals("$.status", "SUCCEEDED");
const wait = new sfn.Wait(scope, "WaitCompile", {
time: sfn.WaitTime.duration(waitTime),
});
const definition = wait
.next(
new sfn.Choice(scope, "Job Complete?")
.when(condFailed, invokeErrorHandler)
.when(
condSucceeded,
new tasks.LambdaInvoke(scope, "invokeCompileReport", {
lambdaFunction: compileReport,
})
)
compileReport: lambda.Function,
reviewer: lambda.Function,
publishReport: lambda.Function,
errorHandler: lambda.Function,
delay?: cdk.Duration,
sfnRole?: iam.IRole
): sfn.StateMachine {
const waitTime = delay || cdk.Duration.minutes(10);
const invokeErrorHandler = new tasks.LambdaInvoke(
scope,
"InvokeErrorHandler",
{ lambdaFunction: errorHandler }
);
const condFailed = sfn.Condition.stringEquals("$.status", "FAILED");
const condSucceeded = sfn.Condition.stringEquals("$.status", "SUCCEEDED");
const wait = new sfn.Wait(scope, "WaitCompile", {
time: sfn.WaitTime.duration(waitTime),
});
const definition = wait
.next(
new sfn.Choice(scope, "Job Complete?")
.when(condFailed, invokeErrorHandler)
.when(
condSucceeded,
new tasks.LambdaInvoke(scope, "invokeCompileReport", {
lambdaFunction: compileReport,
})
)
)