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 to 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:

import json import boto3 s3 = boto3.resource('s3') dynamodb = boto3.resource('dynamodb') table = dynamodb.Table('Table') def lambda_handler(event, context): bucket_list = [] for b in s3.buckets.all(): print(b.name) bucket_list.append(b.name) response = "done" table.put_item( Item = { "Update": response } ) return { "statusCode": 200, "body": bucket_list }

Thank you in advance!!

Apr 29, 2022 in AWS by Soham
• 9,710 points

edited 4 days ago 10 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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