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?

posta un anno fa239 visualizzazioni
1 Risposta
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
ESPERTO
con risposta un anno fa
  • thanks, that worked after I'd got myself untangled from all the quotation marks

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande