Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(stepfunctions): add stateMachineRevisionId property to StateMachine #26443

Merged
merged 4 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'] },
});
});
});