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: easy access to fields in execution context object #25415

Closed
1 of 2 tasks
suhussai opened this issue May 3, 2023 · 3 comments · Fixed by #25646
Closed
1 of 2 tasks

stepfunctions: easy access to fields in execution context object #25415

suhussai opened this issue May 3, 2023 · 3 comments · Fixed by #25646
Assignees
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@suhussai
Copy link

suhussai commented May 3, 2023

Describe the feature

Add functions for accessing fields like name or id from the execution context object. We already have a function for accessing the Task Token:

public static get taskToken(): string {

Use Case

For accessing the task token, we can do something like this:

sfn.JsonPath.taskToken

However, when it comes to accessing something like the name of the Execution, we have to do something like this:

sfn.JsonPath.stringAt("$$.Execution.Name")

Proposed Solution

Add functions for getting all of the remaining fields from the context object.

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.72.0

Environment details (OS name and version, etc.)

macOS 12.6.5

@suhussai suhussai added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels May 3, 2023
@github-actions github-actions bot added the @aws-cdk/aws-stepfunctions Related to AWS StepFunctions label May 3, 2023
@peterwoodworth peterwoodworth added p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels May 3, 2023
@peterwoodworth
Copy link
Contributor

Thanks for the request, we'll probably need contributor support for this feature to be realized

@tejasmr
Copy link
Contributor

tejasmr commented May 12, 2023

I can help with this if no one is already working on this

Just for clarification: Considering the example JSON for context object

{
    "Execution": {
        "Id": "arn:aws:states:us-east-1:123456789012:execution:stateMachineName:executionName",
        "Input": {
           "key": "value"
        },
        "Name": "executionName",
        "RoleArn": "arn:aws:iam::123456789012:role...",
        "StartTime": "2019-03-26T20:14:13.192Z"
    },
    "State": {
        "EnteredTime": "2019-03-26T20:14:13.192Z",
        "Name": "Test",
        "RetryCount": 3
    },
    "StateMachine": {
        "Id": "arn:aws:states:us-east-1:123456789012:stateMachine:stateMachineName",
        "Name": "name"
    },
    "Task": {
        "Token": "h7XRiCdLtd/83p1E0dMccoxlzFhglsdkzpK9mBVKZsp7d9yrT1W"
    }
}

Assuming that we have to implement functions for the below fields. Let me know if there needs to be any additions/deletions to the below list.

  1. $$.Execution.Id - type string
  2. $$.Execution.Input - should the type be any?
  3. $$.Execution.Name - type string
  4. $$.Execution.RoleArn - type string
  5. $$.Execution.StartTime - should the type be string or convert it to Date?
  6. $$.State.EnteredTime - should the type be Date or convert it to Date?
  7. $$.State.Name - type string
  8. $$.State.RetryCount - type number
  9. $$.StateMachine.Id - type string
  10. $$.StateMachine.Name - type string
  11. $$.Task.Token - type string - ALREADY IMPLEMENTED

Need clarification for the questions highlighted above regarding the types the functions should return.

Cheers,
Tejas

@colifran colifran self-assigned this May 18, 2023
@mergify mergify bot closed this as completed in #25646 May 26, 2023
mergify bot pushed a commit that referenced this issue May 26, 2023
This PR adds additional getters to allow easy access to context object fields. We currently have getters allowing easy access to the entire context object and the context object task token field. This adds getters for the following additional context object fields:
- Execution id
- Execution input
- Execution name
- Execution role arn
- Execution start time
- State entered time
- State name
- State retry count
- State machine id
- State machine name

Closes #25415

----

*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.

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 effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants