How to write item, with Null attribute, to Dynamodb through BatchWriteItem task in AWS Step function

0

I am attempting to use aws step functions with the batchwriteitem task for dynamodb.

Unfortunately, the step function throws an error suggesting "The field "NULL" is not supported by Step Functions". But this is how AWS SDK documentation suggests we label null values in API call. If the "NULL" value isn't expected, then how am I supposed to write an item, that has a Null attribute, to Dynamodb through BatchWriteItem task in AWS Step functions

Example task in Step function which is causing step function ASL error. I tried changing "NULL" to "Null" or "null". And none of these work?

"BatchWriteItem": {
    "Type": "Task",
    "End": true,
    "Parameters": {
        "RequestItems": {
            "sample-dynamodb-table": [
                {
                    "PutRequest": {
                        "Item": {
                            "PK": {
                                "S": "trash"
                            },
                            "SK": {
                                "S": "trash"
                            },
                            "value": {
                                "NULL": true
                            }
                        }
                    }
                }
            ]
        }
    },
    "Resource": "arn:aws:states:::aws-sdk:dynamodb:batchWriteItem"
}
1 Answer
2
Accepted Answer

Its a little bit funny, but its based on Java SDK V2 AttributeValue and should be set as Nul.

"BatchWriteItem": {
    "Type": "Task",
    "End": true,
    "Parameters": {
        "RequestItems": {
            "sample-dynamodb-table": [
                {
                    "PutRequest": {
                        "Item": {
                            "PK": {
                                "S": "trash"
                            },
                            "SK": {
                                "S": "trash"
                            },
                            "value": {
                                "Nul": true
                            }
                        }
                    }
                }
            ]
        }
    },
    "Resource": "arn:aws:states:::aws-sdk:dynamodb:batchWriteItem"
}
profile pictureAWS
EXPERT
answered a year ago
profile pictureAWS
EXPERT
reviewed a year ago
  • Ah wow Thank you! Where might I have found this? I had been searching for a while. Is this documented in step function ASL docs anywhere? Or maybe somewhere else?

  • I don't believe its documented, it was something I discovered recently myself. I will bring it up with the documentation team to highlight this. Same scenario occurs for other attributes with step functions following pascal casing, for example string sets which are normally SS are defined in StepFunctions as Ss.

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