Skip to content

Commit 3e47d1b

Browse files
authored
feat(stepfunctions): add stateMachineRevisionId property to StateMachine (#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*
1 parent 64e4f41 commit 3e47d1b

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

packages/aws-cdk-lib/aws-stepfunctions/lib/state-machine.ts

+7
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,12 @@ export class StateMachine extends StateMachineBase {
407407
*/
408408
public readonly stateMachineType: StateMachineType;
409409

410+
/**
411+
* Identifier for the state machine revision, which is an immutable, read-only snapshot of a state machine’s definition and configuration.
412+
* @attribute
413+
*/
414+
public readonly stateMachineRevisionId: string;
415+
410416
constructor(scope: Construct, id: string, props: StateMachineProps) {
411417
super(scope, id, {
412418
physicalName: props.stateMachineName,
@@ -451,6 +457,7 @@ export class StateMachine extends StateMachineBase {
451457
resourceName: this.physicalName,
452458
arnFormat: ArnFormat.COLON_RESOURCE_NAME,
453459
});
460+
this.stateMachineRevisionId = resource.attrStateMachineRevisionId;
454461
}
455462

456463
/**

packages/aws-cdk-lib/aws-stepfunctions/test/state-machine.test.ts

+22
Original file line numberDiff line numberDiff line change
@@ -579,4 +579,26 @@ describe('State Machine', () => {
579579
DeletionPolicy: 'Retain',
580580
});
581581
});
582+
583+
test('stateMachineRevisionId property uses attribute reference', () => {
584+
// GIVEN
585+
const stack = new cdk.Stack();
586+
587+
// WHEN
588+
const stateMachine = new sfn.StateMachine(stack, 'MyStateMachine', {
589+
stateMachineName: 'MyStateMachine',
590+
definitionBody: sfn.DefinitionBody.fromChainable(new sfn.Pass(stack, 'Pass')),
591+
});
592+
593+
new sfn.CfnStateMachineVersion(stack, 'MyStateMachineVersion', {
594+
stateMachineRevisionId: stateMachine.stateMachineRevisionId,
595+
stateMachineArn: stateMachine.stateMachineArn,
596+
});
597+
598+
// THEN
599+
Template.fromStack(stack).hasResourceProperties('AWS::StepFunctions::StateMachineVersion', {
600+
StateMachineArn: { Ref: 'MyStateMachine6C968CA5' },
601+
StateMachineRevisionId: { 'Fn::GetAtt': ['MyStateMachine6C968CA5', 'StateMachineRevisionId'] },
602+
});
603+
});
582604
});

0 commit comments

Comments
 (0)