How to configure step function dynamodb:putItem parameter to include JSON Item data JSON structure from previous step?

0

How do I configure the step function dynamodb:putItem parameters to include JSON Item data JSON structure from previous step?

States:
        APIGatewayInvokeGetDealers:
          Type: Task
          OutputPath: $.ResponseBody.Items                                  <---------------
          Resource: arn:aws:states:::apigateway:invoke
          Parameters:
            ApiEndpoint: "${ApiEndpoint}"
            Method: GET
            Stage: devtest
            #Path: /clients/$.Id/dealers
            Path.$: States.Format('/clients/{}/dealers', $.Id)
            RequestBody:
              Payload: Hello from Step Functions!
            AuthType: IAM_ROLE
          Next: MapDealers
        MapDealers:
          Type: Map
          ItemProcessor:
            ProcessorConfig:
              Mode: INLINE
            StartAt: DynamoDBPutDealer
            States:
              DynamoDBPutDealer:
                Type: Task
                Resource: arn:aws:states:::dynamodb:putItem
                Parameters:
                  TableName: "${DealerImport}"
                  Item:
                    Id.$: $.Id
                    DealerData.$: States.Format('{}', $)                                      <-------- Works, but excludes the double quotes within the JSON structure.  
                End: true

Using just $ or "$" above causes the exception: "The field "Id" is not supported by Step Functions"

wally
asked a year ago439 views
1 Answer
0

Hi there,

Having a look at your data structure:

Item:
 Id.$: $.Id
 DealerData.$: States.Format('{}', $)             

The reason why you could be facing the issue ""The field "Id" is not supported by Step Functions" is that the "Id" isn't in a string format or of a data type that is expected as per [1] [2]. I tested a similar setup in my test env and I was able to used "$.id" using the below snippet:

    "DynamoDB PutItem": {
      "Type": "Task",
      "Resource": "arn:aws:states:::dynamodb:putItem",
      "Parameters": {
        "TableName": "stepfunctionreplication",
        "Item": {
          "Id": {
            "S.$": "$.Id",
            "S.$": "States.Format('{}', $.DealerData)"
          }
        }
      },
      "End": true
    }

However, we would like to understand more about the output coming from "APIGatewayInvokeGetDealers" hence I kindly ask that you please please open a support case with AWS using the following link under the Step Functions service so we can troubleshoot further. [3]

References:

[1] https://docs.aws.amazon.com/step-functions/latest/dg/connect-ddb.html

[2] https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html

[3] https://support.console.aws.amazon.com/support/home#/case/create

AWS
answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions