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?

gefragt vor einem Jahr236 Aufrufe
1 Antwort
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
EXPERTE
beantwortet vor einem Jahr
  • thanks, that worked after I'd got myself untangled from all the quotation marks

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen