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 réponse
2
Réponse acceptée

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
répondu il y a un an
profile pictureAWS
EXPERT
vérifié il y a un an
  • 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.

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions