Skip to content

Commit

Permalink
docs(stepfunctions): replace definition with definitionBody in readm …
Browse files Browse the repository at this point in the history
…of aws-stepfunctions (#27110)

`definition` in Construct Props of `sfn.StateMachine` is already deprecated and `definitionBody` is recommended.
README and docs still use `definition` in examples, and it's misleading for users.

I replaced `definition` with `definitionBody` and `sfn.DefinitionBody.fromChainable(...)` in them.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
ymhiroki authored Sep 12, 2023
1 parent 444cc7d commit c5e0836
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions packages/aws-cdk-lib/aws-stepfunctions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const definition = submitJob
.otherwise(waitX));

new sfn.StateMachine(this, 'StateMachine', {
definition,
definitionBody: sfn.DefinitionBody.fromChainable(definition),
timeout: Duration.minutes(5),
comment: 'a super cool state machine',
});
Expand All @@ -76,7 +76,7 @@ all states reachable from the start state:
const startState = new sfn.Pass(this, 'StartState');

new sfn.StateMachine(this, 'StateMachine', {
definition: startState,
definitionBody: sfn.DefinitionBody.fromChainable(startState),
});
```

Expand Down Expand Up @@ -565,7 +565,7 @@ const chain = sfn.Chain.start(custom)
.next(finalStatus);

const sm = new sfn.StateMachine(this, 'StateMachine', {
definition: chain,
definitionBody: sfn.DefinitionBody.fromChainable(chain),
timeout: Duration.seconds(30),
comment: 'a super cool state machine',
});
Expand Down Expand Up @@ -610,7 +610,7 @@ const definition = step1
.next(finish);

new sfn.StateMachine(this, 'StateMachine', {
definition,
definitionBody: sfn.DefinitionBody.fromChainable(definition),
});
```

Expand Down Expand Up @@ -712,7 +712,7 @@ class MyStack extends Stack {
.branch(new MyJob(this, 'Slow', { jobFlavor: 'slow' }).prefixStates());

new sfn.StateMachine(this, 'MyStateMachine', {
definition: parallel,
definitionBody: sfn.DefinitionBody.fromChainable(parallel),
});
}
}
Expand Down Expand Up @@ -818,8 +818,10 @@ import * as logs from 'aws-cdk-lib/aws-logs';

const logGroup = new logs.LogGroup(this, 'MyLogGroup');

const definition = sfn.Chain.start(new sfn.Pass(this, 'Pass'));

new sfn.StateMachine(this, 'MyStateMachine', {
definition: sfn.Chain.start(new sfn.Pass(this, 'Pass')),
definitionBody: sfn.DefinitionBody.fromChainable(definition),
logs: {
destination: logGroup,
level: sfn.LogLevel.ALL,
Expand All @@ -832,8 +834,10 @@ new sfn.StateMachine(this, 'MyStateMachine', {
Enable X-Ray tracing for StateMachine:

```ts
const definition = sfn.Chain.start(new sfn.Pass(this, 'Pass'));

new sfn.StateMachine(this, 'MyStateMachine', {
definition: sfn.Chain.start(new sfn.Pass(this, 'Pass')),
definitionBody: sfn.DefinitionBody.fromChainable(definition),
tracingEnabled: true,
});
```
Expand Down Expand Up @@ -864,7 +868,7 @@ const role = new iam.Role(this, 'Role', {

declare const definition: sfn.IChainable;
const stateMachine = new sfn.StateMachine(this, 'StateMachine', {
definition,
definitionBody: sfn.DefinitionBody.fromChainable(definition),
});

// Give role permission to start execution of state machine
Expand All @@ -886,7 +890,7 @@ const role = new iam.Role(this, 'Role', {

declare const definition: sfn.IChainable;
const stateMachine = new sfn.StateMachine(this, 'StateMachine', {
definition,
definitionBody: sfn.DefinitionBody.fromChainable(definition),
});

// Give role read access to state machine
Expand Down Expand Up @@ -915,7 +919,7 @@ const role = new iam.Role(this, 'Role', {

declare const definition: sfn.IChainable;
const stateMachine = new sfn.StateMachine(this, 'StateMachine', {
definition,
definitionBody: sfn.DefinitionBody.fromChainable(definition),
});

// Give role task response permissions to the state machine
Expand All @@ -939,7 +943,7 @@ const role = new iam.Role(this, 'Role', {

declare const definition: sfn.IChainable;
const stateMachine = new sfn.StateMachine(this, 'StateMachine', {
definition,
definitionBody: sfn.DefinitionBody.fromChainable(definition),
});

// Give role permission to get execution history of ALL executions for the state machine
Expand All @@ -955,7 +959,7 @@ const user = new iam.User(this, 'MyUser');

declare const definition: sfn.IChainable;
const stateMachine = new sfn.StateMachine(this, 'StateMachine', {
definition,
definitionBody: sfn.DefinitionBody.fromChainable(definition),
});

//give user permission to send task success to the state machine
Expand Down

0 comments on commit c5e0836

Please sign in to comment.