Skip to content

Commit

Permalink
feat(stepfunctions): add stateMachineRevisionId property to StateMach…
Browse files Browse the repository at this point in the history
…ine (aws#26443)

Expose `stateMachineRevisionId` as a readonly property to StateMachine whose value is a reference to the `StateMachineRevisionId` attribute of the underlying CloudFormation resource.

Closes aws#26440

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
wong-a authored and bmoffatt committed Jul 28, 2023
1 parent 16ad440 commit 5e127b2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/aws-cdk-lib/aws-stepfunctions/lib/state-machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,12 @@ export class StateMachine extends StateMachineBase {
*/
public readonly stateMachineType: StateMachineType;

/**
* Identifier for the state machine revision, which is an immutable, read-only snapshot of a state machine’s definition and configuration.
* @attribute
*/
public readonly stateMachineRevisionId: string;

constructor(scope: Construct, id: string, props: StateMachineProps) {
super(scope, id, {
physicalName: props.stateMachineName,
Expand Down Expand Up @@ -451,6 +457,7 @@ export class StateMachine extends StateMachineBase {
resourceName: this.physicalName,
arnFormat: ArnFormat.COLON_RESOURCE_NAME,
});
this.stateMachineRevisionId = resource.attrStateMachineRevisionId;
}

/**
Expand Down
22 changes: 22 additions & 0 deletions packages/aws-cdk-lib/aws-stepfunctions/test/state-machine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,4 +579,26 @@ describe('State Machine', () => {
DeletionPolicy: 'Retain',
});
});

test('stateMachineRevisionId property uses attribute reference', () => {
// GIVEN
const stack = new cdk.Stack();

// WHEN
const stateMachine = new sfn.StateMachine(stack, 'MyStateMachine', {
stateMachineName: 'MyStateMachine',
definitionBody: sfn.DefinitionBody.fromChainable(new sfn.Pass(stack, 'Pass')),
});

new sfn.CfnStateMachineVersion(stack, 'MyStateMachineVersion', {
stateMachineRevisionId: stateMachine.stateMachineRevisionId,
stateMachineArn: stateMachine.stateMachineArn,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::StepFunctions::StateMachineVersion', {
StateMachineArn: { Ref: 'MyStateMachine6C968CA5' },
StateMachineRevisionId: { 'Fn::GetAtt': ['MyStateMachine6C968CA5', 'StateMachineRevisionId'] },
});
});
});

0 comments on commit 5e127b2

Please sign in to comment.