Praveen Sripati
Praveen Sripati

Reputation: 33545

Not able to insert DynamoDB Item properly from AWS StepFunctions

I have written a state in AWS StepFunctions to insert an an item into the DynamoDB Table as shown below. The output of the Lambda state goes to the input of below the DynamoDB state.

"States":{
   "Update the order table":{
      "Type":"Task",
      "Resource":"arn:aws:states:::dynamodb:putItem",
      "Parameters":{
         "TableName":"OrderTable",
         "Item":{
            "OrderId":{
               "S":"$.OrderId"
            },
            "ItemName":{
               "S":"$.ItemName"
            },
            "Price":{
               "S":"$.Price"
            },
            "CC":{
               "S":"$.CC"
            }
         }
      },
      "End":true
   }
}

The literal strings "$.OrderId", "$.ItemName" and others are getting inserted into the DynamoDB table and not the values from the Lambda function.

enter image description here

So, I removed the double quotes around the "$.OrderId" and I get the below error.

enter image description here

enter image description here

The input to the DynamoDB state is correct, but still I am not able to insert the output of the Lambda into the DynamoDB table.

enter image description here

Any help would be appreciated.

Upvotes: 2

Views: 1448

Answers (1)

Asdfg
Asdfg

Reputation: 12253

This is how your Task definition should look like. Notice $ sign after the datatype for each item attribute.

"States":{
   "Update the order table":{
      "Type":"Task",
      "Resource":"arn:aws:states:::dynamodb:putItem",
      "Parameters":{
         "TableName":"OrderTable",
         "Item":{
            "OrderId":{
               "S.$":"$.OrderId"
            },
            "ItemName":{
               "S.$":"$.ItemName"
            },
            "Price":{
               "S.$":"$.Price"
            },
            "CC":{
               "S.$":"$.CC"
            }
         }
      },
      "End":true
   }
}

Upvotes: 3

Related Questions