AWS CDK Step Function Task - Include list of objects in DynamoPutItem task

Viewed 39

I'm trying to use the DynamoPutItem task to put an entry which includes a list of objects as one of its attributes. I can't find any examples of this being done online so I'm wondering if it is even possible?

This CDK issue seems to be talking about the same thing but that won't work for me, I'm wondering is that only good for lists of strings not objects?

Here is a simplified example of an item I'm trying to put to DDB:

{
  'someKey': 'This will be fine',
  'anotherKey': [
    {
      'ohoh': 'This object and the list it belongs will cause an error'
    }
  ]
}

I've tried numerous combinations of DynamoAttributeValue and JsonPath to no avail :(

Here is an example of some code that I've tried:

new DynamoPutItem(this, 'some id here', {
  item: {
    // this will be fine
    someKey: DynamoAttributeValue.fromString(JsonPath.stringAt('$.someKey'),
    // this will cause an error
    anotherKey: DynamoAttributeValue.listFromJsonPath(JsonPath.stringAt('$.anotherKey')),
  },
  table: myTable,
}

and the error it throws: The field "ohoh" is not supported by Step Functions

1 Answers

If I read the docu here it seems like you need to use:

DynamoAttributeValue.listFromJsonPath(value: anotherKey)
Related