Add a new item to a Dynamodb using a AWS lambda function each time a function is executed with Cloudwatch

0 votes
I'm trying to modify a Dynamodb table each time a Lambda function is executed. Specifically, I create a simple lambda function that returns a list of S3 bucket names and this function run each minute thanks to a Cloudwatch's rule. However, as I said before, my goal is to also update a Dynamodb each time the same function is executed. Specifically I want to add each time a new Item with the same attribute (so let's say the function is executed 1000 times, I want 1K items/rows).

However I don't know how to do it. Any suggestions? Here's the code:
Feb 14, 2022 in AWS by Rahul
• 2,120 points
598 views

1 answer to this question.

0 votes

The problem here is that the PutItem command does overwrite exiting items if they are the same. So every time you try to insert Update= Done it overwrites the same item. So you need to put something unique in your item so that a new item is created and the old one is not overwritten. You could use either UUID or the time of execution.

from datetime import datetime

[...]

table.put_item(
    Item = {
        "Update": response,
        "ProcessingTime": datetime.now().isoformat()
    }
)
answered Feb 14, 2022 by Rahul
• 2,120 points

Related Questions In AWS

0 votes
1 answer

How to create a Lambda function with AWS CLI?

Hi@akhtar, To create a function, you need a ...READ MORE

answered Nov 5, 2020 in AWS by MD
• 95,460 points
1,235 views
0 votes
1 answer

How to delete a Lambda function using AWS CLI?

Hi@akhtar, You can delete a Lambda function. To ...READ MORE

answered Nov 5, 2020 in AWS by MD
• 95,460 points
2,484 views
0 votes
1 answer

How to link AWS Lambda function to Amazon CloudWatch ?

In order to create Log Group and ...READ MORE

answered Jul 20, 2018 in AWS by datageek
• 2,540 points
1,553 views
+1 vote
1 answer

How to add SSL certificate to AWS EC2 with the help of new AWS Certificate Manager service

refer this link  https://aws.amazon.com/certificate-manager/faqs/ You can't install the certificates ...READ MORE

answered Jul 19, 2018 in AWS by Priyaj
• 58,020 points
1,864 views
0 votes
1 answer

How to set-up DynamoDB trigger using AWS Lambda?

Well this code worked for me. You ...READ MORE

answered Aug 20, 2018 in AWS by Archana
• 4,170 points
2,841 views
0 votes
1 answer

Pass account id of an AWS sub account using a variable as an argument in CloudWatch Alarm Actions with python (boto3)?

Python String and Integer concatenation >>> print("arn:aws:swf:us-east-2:{0}:action/actions/AWS_EC2.InstanceId.Stop/1.0".format(acccnum)) arn:aws:swf:us-east-2:12312312312312:action/actions/AWS_EC2.InstanceId.Stop/1.0 >>> print("arn:aws:swf:us-east-2:" ...READ MORE

answered Oct 5, 2018 in AWS by Priyaj
• 58,020 points
1,586 views
0 votes
1 answer

What is AWS?

Amazon Web Services or AWS is the ...READ MORE

answered Dec 13, 2021 in AWS by Rahul
• 2,120 points
709 views
0 votes
1 answer

what is ARN in AWS?

Amazon Resource Names (ARN) uniquely identify AWS ...READ MORE

answered Jan 10, 2022 in AWS by Rahul
• 2,120 points
437 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP