What is AWS Lambda?
In Aws, we can run code using the computation service Lambda without setting up or maintaining servers.
In essence, this suggests that AWS Lambda development may be done with no concern for setting up servers or other infrastructure.
When data in an Amazon S3 bucket or an Amazon DynamoDB table changes, for example, your code can be launched in response using Lambda.
Create an AWS Lambda:
- Click on the Lambda Console
- Choose Create Function
- Click Create from scratch
- Give your AWS Lambda a name
- Select Python 3.6
- Click Create Function


Give the run time, the basic information (such as the function name), and, most importantly, the language you chose to construct your function.


import boto3
from uuid import uuid4
def lambda_handler(event, context):
s3 = boto3.client("s3")
dynamodb = boto3.resource('dynamodb')
for record in event['Records']:
bucket_name = record['s3']['bucket']['name']
object_key = record['s3']['object']['key']
size = record['s3']['object'].get('size', -1)
event_name = record ['eventName']
event_time = record['eventTime']
dynamoTable = dynamodb.Table('newtable')
dynamoTable.put_item(
Item={'unique': str(uuid4()), 'Bucket': bucket_name, 'Object': object_key,'Size': size, 'Event': event_name, 'EventTime': event_time})
Once done, make sure the name for the Dynamo table = “new table” and the Partition key should be Unique and similar to the name of the dynamo table.
Trigger:
Trigger Configuration:


Create a Dynamo DB table first.



Dynamo DB, which is created by the s3 bucket, is where the information is triggered. Its distinct identifier, bucket, event, event time, object, and will also indicate the size
Conclusion:-
This blog post demonstrated how to set up an S3 Trigger in AWS with Lambda and DynamodDB.
To read more about DevOps.
Happy Learning!!