How to Add item to string_set on Dynamodb with Boto3

It looks like you figured out a method for yourself, but for others who come here looking for an answer:

  1. Your 'Key' syntax needs a data type (like 'S' or 'N')
  2. You need to use "SS" as the data type in ExpressionAttributeValues, and
  3. You don't need "set" in your ExpressionAttributeValues.

Here's an example I just ran (I had an existing set, test_set, with 4 existing values, and I'm adding a 5th, the string 'five'):

import boto3
db = boto3.client("dynamodb")
db.update_item(TableName=TABLE,
               Key={'id':{'S':'test_id'}},
               UpdateExpression="ADD test_set :element",
               ExpressionAttributeValues={":element":{"SS":['five']}})

So before, the string set looked like ['one','two','three','four'], and after, it looked like ['one','two','three','four','five']