You want an AWS Lambda function to automatically log the names of files uploaded to an S3 bucket. Which setup is the most appropriate?
hard📝 Best Practice Q8 of 15
AWS - Lambda
You want an AWS Lambda function to automatically log the names of files uploaded to an S3 bucket. Which setup is the most appropriate?
AManually invoke the Lambda function after each file upload
BSchedule the Lambda function to run every hour and scan the S3 bucket for new files
CConfigure S3 event notifications to trigger the Lambda function on 'ObjectCreated' events
DUse CloudWatch Logs to monitor S3 bucket and trigger Lambda
Step-by-Step Solution
Solution:
Step 1: Understand event-driven architecture
S3 can trigger Lambda on specific events like 'ObjectCreated'.
Step 2: Choose automatic trigger
Configure S3 event notifications to trigger the Lambda function on 'ObjectCreated' events uses S3 event notifications to invoke Lambda immediately on uploads.
Step 3: Evaluate other options
Schedule the Lambda function to run every hour and scan the S3 bucket for new files is inefficient polling; C is manual; D is incorrect as CloudWatch Logs doesn't monitor S3 directly.
Final Answer:
Configure S3 event notifications to trigger the Lambda function on 'ObjectCreated' events -> Option C
Quick Check:
S3 event notifications trigger Lambda on uploads [OK]
Quick Trick:Use S3 event notifications for automatic Lambda triggers [OK]
Common Mistakes:
MISTAKES
Using scheduled polling instead of event triggers
Manually invoking Lambda after uploads
Misunderstanding CloudWatch Logs role
Master "Lambda" in AWS
9 interactive learning modes - each teaches the same concept differently