Here's my use case, I need to add and update entries in a DynamoDB table like this:
If the partition key doesn't exist, add it and add a new one element list containing a string value. If the partition key does exist, add a new string to its list attribute. I have code that Python/boto3 looks like this:
response = ddb_client.update_item(
TableName=target_ddb_table,
Key={'email-hash': {'S' : encrypted_hashed_pw},},
ExpressionAttributeValues={ ":my_value":[{"S":"test"}], ":empty_list":[] },
UpdateExpression='SET site_ids = list_append(if_not_exists(site_ids, :empty_list), :my_value)',
ReturnValues='ALL_NEW'
)
I'm getting these errors, I realize that I'm doing something dumb here:re
Invalid type for parameter ExpressionAttributeValues.:empty_list, value: [], type: <class 'list'>, valid types: <class 'dict'>
Invalid type for parameter ExpressionAttributeValues.:my_value, value: [{'S': 'test'}], type: <class 'list'>, valid types: <class 'dict'>