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 in AWS by Rahul
• 2,080 points
59 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 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,360 points
488 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,360 points
725 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
894 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,080 points
899 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,150 points
2,143 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,080 points
854 views
0 votes
2 answers

What is AWS?

AWS stands for Amazon Web Services. AWS for ...READ MORE

answered Dec 15, 2021 in AWS by richamalhotra
• 140 points
47 views
0 votes
1 answer

Unable to download aws s3 glacier objects

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

answered Feb 15 in AWS by Rahul
• 2,080 points
84 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP