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

(step-functions): (add keyPath in item reader) #32602

Open
2 tasks
Nicolas-SB opened this issue Dec 20, 2024 · 4 comments
Open
2 tasks

(step-functions): (add keyPath in item reader) #32602

Nicolas-SB opened this issue Dec 20, 2024 · 4 comments
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. investigating This issue is being investigated and/or work is in progress to resolve the issue. p3

Comments

@Nicolas-SB
Copy link

Nicolas-SB commented Dec 20, 2024

Describe the feature

Analogous to the new bucketNamePath parameter introduced in #31619 I expected to find a keyPath parameter when creating a item reader.

If the already existing "key" parameter is supposed to implicitly support JsonPath, then the naming and docstring of the parameter does not clearly express that.

Use Case

I get an input event containing the dynamically generated key of the manifest file and want to reference it. The constructor of the class, in my case S3JsonItemReader, is vague about how to achieve this. In the AWS console for step functions I can just give it a JsonPath, the CDK constructor tells me to give it a concrete key.

Proposed Solution

Either add a new parameter key_path analogous to bucket_name_path or update the docstring of parameter key to point out clearly that JsonPath is supported.

Other Information

On a side-note, the docstring of bucket and bucket_name_path tells me the default is "S3 bucket will be determined from" - I do not quite understand what this is supposed to tell me

Acknowledgements

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

CDK version used

2.173.2

Environment details (OS name and version, etc.)

macOS Sequoia 15.2

@Nicolas-SB Nicolas-SB added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Dec 20, 2024
@github-actions github-actions bot added the @aws-cdk/aws-stepfunctions Related to AWS StepFunctions label Dec 20, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Dec 20, 2024
@khushail khushail self-assigned this Dec 20, 2024
@khushail
Copy link
Contributor

Hi @Nicolas-SB , thanks for reaching out. I see that in the AWS Stepfunction README file, it looks like the JSON Path is supported for the parameterkey -

https://github.com/aws/aws-cdk/blob/v2.173.2/packages/aws-cdk-lib/aws-stepfunctions/README.md

Screenshot 2024-12-20 at 11 08 07 AM

Hope this is what you are looking for. Let me know if your ask is different.

@khushail khushail added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. p3 and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Dec 20, 2024
@Nicolas-SB
Copy link
Author

Thanks for the quick answer! I am working with python CDK and the S3JsonItemReader class looks the following:

Screenshot 2024-12-20 at 20 51 16

According to the description it seems like key would not support JsonPath. For the bucket there seems to be one parameter specifically for a predefined bucket and one specifically for a JsonPath. Therefore I assumed that the key parameter only supports a predefined key and the class is missing a parameter for a JsonPath.

I guess this misunderstanding could be resolved by adjusting the description to mention that JsonPath is supported.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Dec 20, 2024
@Nicolas-SB
Copy link
Author

Nicolas-SB commented Dec 20, 2024

Edit:

I got it working using the code:

sfn.S3JsonItemReader(
    bucket_name_path=sfn.JsonPath.string_at("$.manifest_bucket"),
    key=sfn.JsonPath.string_at("$.data_manifest_key"),
)

So it is supported, but I stand by my point that the explanation contained in the docstring (see comment above) is rather misleading and does a poor job of explaining how to use the class.


Something does not seem to be quite right. I have the following python cdk code:

sfn.DistributedMap(
  scope=scope,
  id="my_id",
  item_reader=sfn.S3JsonItemReader(bucket_name_path="$.manifest_bucket", key="$.data_manifest_key")
)

Which produces a DistributedMap with the following setting:

Screenshot 2024-12-20 at 22 09 07

In the console it works once I select this setting:

Screenshot 2024-12-20 at 22 15 54

It seems like this setting is currently not supported by Python CDK?

@khushail khushail added the effort/small Small work item – less than a day of effort label Dec 20, 2024
@khushail
Copy link
Contributor

@Nicolas-SB , I see that you got it working in Typescript so it should work in python as well. I will try to repro this in python and share the code.

However I agree that there should have been clear explanation reg. Key JSONPATH. So marking it as P3 which means community contributions are welcome in this regard.

@khushail khushail added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Dec 20, 2024
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. investigating This issue is being investigated and/or work is in progress to resolve the issue. p3
Projects
None yet
Development

No branches or pull requests

2 participants