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,080 points
404 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,080 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,440 points
987 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,440 points
2,061 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,530 points
1,338 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,090 points
1,598 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,641 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,090 points
1,376 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,080 points
490 views
0 votes
1 answer

Unable to download aws s3 glacier objects

You can fix the issue with the ...READ MORE

answered Feb 15, 2022 in AWS by Rahul
• 2,080 points
1,279 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