I am creating a Infrastructure-as-Code for a Step Functions Machine. One of these states is of type 'Task' which performs a DynamoUpdateItem on a DynamoDB table.
The code looks as following:
const updateDDB = new tasks.DynamoUpdateItem(this, 'Update item into DynamoDB', {
key: { ['Task'] : tasks.DynamoAttributeValue.fromString('Processing') },
table: table,
updateExpression: 'SET LastRun = :label',
expressionAttributeValues: {
':label.$': DynamoAttributeValue.fromString(JsonPath.stringAt('$$.Execution.StartTime')),
},
resultPath: JsonPath.DISCARD,
});
However, I keep getting an error saying the schema validation failed, and that
"The value for the field ':label.$' must be a STRING that contains a JSONPath but was an OBJECT at /States/Update item into DynamoDB/Parameters'"
How the heck is it not a string?!
I have tried writing it as [':label.$'], or even writing a .toString() function at the end of the JsonPath method
expressionAttributeValues: {
':label.$': (DynamoAttributeValue.fromString(JsonPath.stringAt('$$.Execution.StartTime').toString())),
},
But nothing seems to work. I keep getting the same issue claiming that it's not a string.
Using something like JSON.stringify() doesn't work either because expressionAttributeValues takes a key and matches it with a DynamoAttributeValue.