2

I'm trying to craft a Lambda function using event data from an S3 trigger I have setup on a bucket. My first function works as expected and prints the event data. However, when I try and pull that event data into the next function the bucket name does not print which is what I expected. What am I missing here? Can I not pull event data into other functions to grab pieces of it?

import boto3

s3 = boto3.client("s3")

def lambda_handler(event, context):
    s3_upload_record = event
    print(s3_upload_record)
    
def print_bucket_name(s3_upload_record):
    bucket_name = s3_upload_record["Records"][0]["s3"]["bucket"]["name"]
    print(bucket_name)
0

1 Answer 1

2

Your function print_bucket_name is not called at all. I think you should be using:

def lambda_handler(event, context):
    s3_upload_record = event
    print_bucket_name(s3_upload_record)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.