Skip to content

Commit

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

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

Closes #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 Jul 20, 2023
1 parent 64e4f41 commit 3e47d1b
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 3e47d1b

Please sign in to comment.