As I develop an Infrastructure-as-Code for a Step Functions Machine, one of the states is a 'Task' type that executes a DynamoUpdateItem on a DynamoDB table.
The code snippet is as follows:
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,
});
Despite my efforts, I keep encountering an error related to schema validation. The error message indicates 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'"
It's puzzling why it's not recognizing it as a string!
I have attempted variations like [':label.$'] and adding a .toString() function after the JsonPath method
expressionAttributeValues: {
':label.$': (DynamoAttributeValue.fromString(JsonPath.stringAt('$$.Execution.StartTime').toString())),
},
However, none of these solutions seem to resolve the issue. The same error persists, claiming it's not a string.
Even using JSON.stringify() doesn't provide a solution because expressionAttributeValues expects a key-value pair matching a DynamoAttributeValue.