Skip to content

Commit

Permalink
chore: remove deprecated step functions definition prop (#257)
Browse files Browse the repository at this point in the history
Fixes #239
  • Loading branch information
jogold authored Feb 23, 2024
1 parent 347db65 commit 176f33f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
27 changes: 14 additions & 13 deletions src/ssl-server-test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Rule, RuleTargetInput, Schedule } from 'aws-cdk-lib/aws-events';
import { SfnStateMachine } from 'aws-cdk-lib/aws-events-targets';
import { PolicyStatement } from 'aws-cdk-lib/aws-iam';
import { ITopic, Topic } from 'aws-cdk-lib/aws-sns';
import { Choice, Condition, Fail, FieldUtils, JsonPath, Pass, StateMachine, TaskInput, TaskMetricsConfig, TaskStateBase, TaskStateBaseProps, Wait, WaitTime } from 'aws-cdk-lib/aws-stepfunctions';
import { Choice, Condition, DefinitionBody, Fail, FieldUtils, JsonPath, Pass, StateMachine, TaskInput, TaskMetricsConfig, TaskStateBase, TaskStateBaseProps, Wait, WaitTime } from 'aws-cdk-lib/aws-stepfunctions';
import { LambdaInvoke } from 'aws-cdk-lib/aws-stepfunctions-tasks';
import { Construct } from 'constructs';
import { AnalyzeFunction } from './analyze-function';
Expand Down Expand Up @@ -150,18 +150,19 @@ class SslServerTestStateMachine extends Construct {
const fail = new Fail(this, 'Fail');

this.stateMachine = new StateMachine(this, 'StateMachine', {
definition: startAnalysis
.next(wait)
.next(pollAnalysis)
.next(new Choice(this, 'Is Ready ?')
.when(Condition.stringEquals('$.status', 'READY'), extractGrade.next(
new Choice(this, 'Is Grade Below Minimum?')
.when(Condition.stringLessThanJsonPath('$$.Execution.Input.minimumGrade', '$.grade'), notify)
.otherwise(new Pass(this, 'Pass')),
))
.when(Condition.stringEquals('$.status', 'ERROR'), fail)
.otherwise(wait),
),
definitionBody: DefinitionBody.fromChainable(
startAnalysis
.next(wait)
.next(pollAnalysis)
.next(new Choice(this, 'Is Ready ?')
.when(Condition.stringEquals('$.status', 'READY'), extractGrade.next(
new Choice(this, 'Is Grade Below Minimum?')
.when(Condition.stringLessThanJsonPath('$$.Execution.Input.minimumGrade', '$.grade'), notify)
.otherwise(new Pass(this, 'Pass')),
))
.when(Condition.stringEquals('$.status', 'ERROR'), fail)
.otherwise(wait)),
),
timeout: Duration.hours(1),
});
}
Expand Down
16 changes: 9 additions & 7 deletions src/toolkit-cleaner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,15 @@ export class ToolkitCleaner extends Construct {
});

const stateMachine = new sfn.StateMachine(this, 'Resource', {
definition: getStackNames
.next(stacksMap.iterator(extractTemplateHashes))
.next(flattenHashes)
.next(new sfn.Parallel(this, 'Clean')
.branch(cleanObjects)
.branch(cleanImages))
.next(sumReclaimed),
definitionBody: sfn.DefinitionBody.fromChainable(
getStackNames
.next(stacksMap.iterator(extractTemplateHashes))
.next(flattenHashes)
.next(new sfn.Parallel(this, 'Clean')
.branch(cleanObjects)
.branch(cleanImages))
.next(sumReclaimed),
),
});

const rule = new Rule(this, 'Rule', {
Expand Down

0 comments on commit 176f33f

Please sign in to comment.