Skip to content

(stepfunctions): Expose StateMachineRevisionId attribute from StateMachine L2 construct #26440

@wong-a

Description

@wong-a

Describe the feature

AWS::StepFunctions::StateMachine has a StateMachineRevisionId read-only attribute which changes when the state machine is updated and produces a new revision. It can be used with CfnStateMachineVersion to automatically create a new state machine version when there is a new revision.

StateMachine should expose this property directly for convenience.

The current workaround is read the value from the L1. For example:

// StateMachine
const stateMachine = new sfn.StateMachine(this, 'myStateMachine', {
  definition: new sfn.Pass(this, 'DefineRepositories', { result: sfn.Result.fromString("version 2") })
});

// StateMachineRevisionId is not exposed by the L2 Construct yet,
// so we need to reach down to the L1 to read the attribute
const cfnStateMachine = stateMachine.node.defaultChild as sfn.CfnStateMachine;
const revisionId = cfnStateMachine.attrStateMachineRevisionId

// Version that always points to the latest revision by using `stateMachineRevisionId`
const version = new sfn.CfnStateMachineVersion(this, 'Version', {
  stateMachineArn: stateMachine.stateMachineArn,
  stateMachineRevisionId: revisionId,
});

Use Case

StateMachineRevisionId is not accessible without using the L1. See above

Proposed Solution

Add a readonly property stateMachineRevisionId to StateMachine's properties. It can be assigned a value after the constructor creates the CfnStateMachine instance here: https://github.com/aws/aws-cdk/blob/efb0a4c785bb794e3ee2e7444b29e4a00d7d28f1/packages/aws-cdk-lib/aws-stepfunctions/lib/state-machine.ts#L434C11-L442

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.87.0

Environment details (OS name and version, etc.)

MacOS 12.6.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-stepfunctionsRelated to AWS StepFunctionsfeature-requestA feature should be added or improved.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions