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

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

Closed
1 of 2 tasks
wong-a opened this issue Jul 20, 2023 · 1 comment · Fixed by #26443
Closed
1 of 2 tasks
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged.

Comments

@wong-a
Copy link
Contributor

wong-a commented Jul 20, 2023

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

@wong-a wong-a added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jul 20, 2023
@github-actions github-actions bot added the @aws-cdk/aws-stepfunctions Related to AWS StepFunctions label Jul 20, 2023
@wong-a wong-a changed the title (aws_stepfunctions): Expose StateMachineRevisionId attribute from StateMachine L2 construct (stepfunctions): Expose StateMachineRevisionId attribute from StateMachine L2 construct Jul 20, 2023
@mergify mergify bot closed this as completed in #26443 Jul 20, 2023
mergify bot pushed a commit that referenced this issue Jul 20, 2023
…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*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

bmoffatt pushed a commit to bmoffatt/aws-cdk that referenced this issue Jul 29, 2023
…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*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant