Writing to a String Set from Lambda

0

I want to write a string set into a DynamoDB table from a Lambda function using table.Put. The best I've come up with so far is:

 def WriteToDB(self):
            
            table.put_item(Item={'RecordingID':self.recordingID,
                            'ANI':self.ani,
                            'DNS':self.dns,
                            'StartTime':self.startTime,
                            'EndTime':self.endTime,
                            'Duration':self.duration,
                            'FilePath':self.filePath,
                            'Direction': self.Direction,
                            'AgentIDs': "'SS': ['test','test4']",
                            'QueueIds': self.QueueIds,
                            'CreatedTime': str(datetime.datetime.now())
                
            })

It's the AgentIDs field I'm concerned with. It's surely just a matter of formatting, and I'm working from here; https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Client.put_item, but I just can't get it. Can someone tell me what the correct formatting is?

asked a year ago229 views
1 Answer
0

The documentation you've linked to is for the DynamoDB Client put_item rather than the Table resource put_item - they are a bit different and you can see that in the documentation.

I also think that the "string set" as described in the documentation is actually a Python list. Try doing this: 'AgentIDs': ['test','test4']

profile pictureAWS
EXPERT
answered a year ago
  • thanks, that worked after I'd got myself untangled from all the quotation marks

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