aws lambda function handler python

H.Dai Source

I am new to AWS, im trying to write a function whenever there is a new object created in s3 bucket, rekognition will start analysis. I looked at AWS documentation for lambda function handler(python), it gives a general syntax structure for handling, but what operators should I use to call the name of new object in s3 bucket? I hardly find any, can anyone please help? thank you so much

import boto3

client = boto3.client('rekognition')
s3 = boto3.resource('s3')
bucket = s3.bucket('my_bucket')
for obj in bucket.object.all():

def my_handler(event,context):
    income_Name = event.***** # not sure what operator here?

    response = client.search_faces_by_image(
           #'Bytes': b'bytes',
           'S3Object': {
              'Bucket': 'my_bucket',
              'Name': income_name,

    return response[]


answered 5 days ago user_default #1

Here is a comprehensive description of the S3 event that is received by Lambda.

Make sure that you have properly configured the Lambda function to be triggered by an S3 event. Then you can decode the notification message sent from S3 to Lambda to get the values you need.

example : s3_key = event['Records'][0]['s3']['object']['key']

comments powered by Disqus