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

[aws-stepfunctions-tasks] Problem with mapping a boolean and a number from an input event in a step function to insert into dynamodb #9007

Closed
michaelwiles opened this issue Jul 10, 2020 · 7 comments · Fixed by #9088
Assignees
Labels
@aws-cdk/aws-stepfunctions-tasks guidance Question that needs advice or information.

Comments

@michaelwiles
Copy link
Contributor

So thank you for upgrading the dynamodb integration from step functions.

I'm now starting to use it.

Firstly, when doing this - the recommended way to map values in a step function:

"alarm_id": DynamoAttributeValue.from_number(JsonPath.number_at("$.detail.alarm_id")),

This is synthesized as "alarm_id":{"N":"-1.8881545897087864e+289"}}

Very weird. Especially since that is what is actually deployed...

Surely that should be

"alarm_id":{"N.$":"$.detail.alarm_id"}}

Then what about when I want to map a boolean?

There is no boolean_at in JsonPath...

So what I really want to know is why access to the constructor of DynamoAttributeValue is not provided because this would solve all my problems...

  • **CDK CLI Version:1.51.0
  • **Node.js Version: 12.16.3
  • **OS: Ubuntu 20.04
  • **Language (Version): Python 3.8
@michaelwiles michaelwiles added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Jul 10, 2020
@shivlaks
Copy link
Contributor

@michaelbrewer - from_number is for the case where you have a number to directly plug in, you'd want to use number_from_string and pass it the parameter you're currently giving it. can you give that a go and let me know how it turns out?

I'll need to dig into the boolean case a bit more, will take a look a bit later today

@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Jul 10, 2020
@michaelwiles
Copy link
Contributor Author

michaelwiles commented Jul 10, 2020

Yes, thank you @shivlaks - I looked at some of the tests and ascertained that is the way to do it.

"alarm_id": DynamoAttributeValue.number_from_string(JsonPath.string_at("$.detail.alarmId")),

works great...

Please let me know if you have something on booleans as I can't find an example mapping a boolean in the tests.

@shivlaks
Copy link
Contributor

@michaelwiles are you attempting to set a boolean based on state input (by selecting part of the path?) we might need to add a booleanFromJsonPath method to support that as there's only fromBoolean that's currently available, which will allow you to set a value, but not select it from the state input.

@michaelwiles
Copy link
Contributor Author

Yes, that's what I am doing - and that's what is needed -> "booleanFromJsonPath"

@michaelwiles
Copy link
Contributor Author

@shivlaks I've created a pull request for this though it's going to need a bit more attention as I don't think I've followed the process properly.

@shivlaks
Copy link
Contributor

@michaelwiles took a quick glance and provided some feedback. let me know if you're running into any issues iterating.
I'm happy to help get this PR filled out and past the goal line :)

@michaelwiles
Copy link
Contributor Author

thank you. will follow up

shivlaks added a commit that referenced this issue Jul 17, 2020
…e input (Json path) (#9088)

It is now possible to map a boolean value from state input using a Json path.

function booleanFromJsonPath added to DynamoAttributeValue which accepts
a Json path

Closes #9007

Co-authored-by: Michael Wiles <michaelwiles@lumkani.com>
Co-authored-by: Shiv Lakshminarayan <shivlaks@amazon.com>
curtiseppel pushed a commit to curtiseppel/aws-cdk that referenced this issue Aug 11, 2020
…e input (Json path) (aws#9088)

It is now possible to map a boolean value from state input using a Json path.

function booleanFromJsonPath added to DynamoAttributeValue which accepts
a Json path

Closes aws#9007

Co-authored-by: Michael Wiles <michaelwiles@lumkani.com>
Co-authored-by: Shiv Lakshminarayan <shivlaks@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-stepfunctions-tasks guidance Question that needs advice or information.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants