AWS Lambda Not Triggering EventBridge Rule with S3 Put Events
Quick question that's been bugging me - I'm trying to implement After trying multiple solutions online, I still can't figure this out. I'm having trouble with an AWS Lambda function that is supposed to be triggered by S3 Put events but doesn’t seem to respond to them when they occur. I've set up an EventBridge rule to listen for S3 events on a specific bucket, but the Lambda function never gets invoked. The EventBridge rule is configured as follows: ```json { "Name": "S3PutEventRule", "EventPattern": { "source": ["aws.s3"], "detail-type": ["AWS API Call via CloudTrail"], "detail": { "eventSource": ["s3.amazonaws.com"], "eventName": ["PutObject"] } }, "State": "ENABLED" } ``` I have also set the target for the rule to my Lambda function, which is defined in the following way: ```javascript const AWS = require('aws-sdk'); exports.handler = async (event) => { console.log('Event:', JSON.stringify(event, null, 2)); // Additional logic... }; ``` In the Lambda console, I’ve added the necessary execution role permissions, allowing it to log to CloudWatch and access the S3 bucket, like this: ```json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents"], "Resource": "*" }, { "Effect": "Allow", "Action": ["s3:GetObject"], "Resource": "arn:aws:s3:::my-bucket/*" } ] } ``` I’ve verified that the event pattern matches the expected S3 events and performed a few manual uploads to the bucket, but the Lambda function doesn’t get invoked at all. Additionally, I've checked the CloudWatch logs for any errors, but there are no entries when I upload objects. I even enabled the EventBridge rule with `aws events enable-rule --name S3PutEventRule`, but it still doesn’t trigger. Am I missing something in the setup, or is there a different way to configure EventBridge to listen to S3 events? Any help would be greatly appreciated! Is there a better approach? For context: I'm using Javascript on Ubuntu 22.04. Am I missing something obvious? I'm working on a microservice that needs to handle this. Any pointers in the right direction? My team is using Javascript for this mobile app.