Problem
In main.go, the event parsing logic only handles two event formats:
- SNS-wrapped legacy S3 Event Notifications
- Direct legacy S3 Event Notifications (
Records[].s3.bucket.name)
Limitations
-
Amazon EventBridge format unsupported:
AWS recommends Amazon EventBridge for S3 event notifications (EventBridge S3 notifications). EventBridge uses a different JSON structure:
{
"version": "0",
"id": "...",
"detail-type": "Object Created",
"source": "aws.s3",
"detail": {
"bucket": { "name": "my-bucket" },
"object": { "key": "das/log.json.gz" }
}
}
When SQS receives EventBridge notifications, fails to parse them, logging an error and skipping the event.
-
s3:TestEvent causes false alarm error logs:
When configuring S3 event notifications in the AWS Console, AWS sends an s3:TestEvent payload ("Event": "s3:TestEvent"). In the current code, this fails parsing and logs an error with the full message body.
Proposed Solution
- Detect and parse EventBridge
aws.s3 event format if legacy S3 records are not present.
- Gracefully identify
s3:TestEvent and log an informational message instead of an error:
slog.Info("Received S3 test event notification, skipping")
- Extract common bucket and key extraction into a helper function
extractS3Events(body string) ([]S3Record, error).
Acceptance Criteria
Problem
In main.go, the event parsing logic only handles two event formats:
Records[].s3.bucket.name)Limitations
Amazon EventBridge format unsupported:
AWS recommends Amazon EventBridge for S3 event notifications (EventBridge S3 notifications). EventBridge uses a different JSON structure:
{ "version": "0", "id": "...", "detail-type": "Object Created", "source": "aws.s3", "detail": { "bucket": { "name": "my-bucket" }, "object": { "key": "das/log.json.gz" } } }When SQS receives EventBridge notifications, fails to parse them, logging an error and skipping the event.
s3:TestEventcauses false alarm error logs:When configuring S3 event notifications in the AWS Console, AWS sends an
s3:TestEventpayload ("Event": "s3:TestEvent"). In the current code, this fails parsing and logs an error with the full message body.Proposed Solution
aws.s3event format if legacy S3 records are not present.s3:TestEventand log an informational message instead of an error:extractS3Events(body string) ([]S3Record, error).Acceptance Criteria
s3:TestEventhandled gracefully without error logs