Review S3 bucket event notifications

Configure S3 notification destinations and event scope for workflows that use object events, and verify delivery.

Description

If an S3 object creation or deletion starts a downstream task, check whether an existing event path already delivers it. For missing events, set the event type, object filter and destination in aws_s3_bucket_notification.

Potential impact

An upload can go unprocessed if its notification never reaches the consumer. Event notifications do not provide a complete audit trail, and consumers can receive the same event more than once.

Remediation

Choose SNS, SQS, Lambda or EventBridge to fit the workflow. Manage all required destinations in one Terraform notification configuration per bucket and make consumers handle duplicates. Applying an empty configuration can clear existing notifications.

Examples

Supply the bucket and an SNS topic in the same Region. The omitted data.aws_iam_policy_document.topic must let S3 publish events from that bucket. Subscribe the intended recipient to the topic.

Before

hcl
resource "aws_s3_bucket" "bucket" {
  bucket = "your-bucket-name"
}

resource "aws_s3_bucket_notification" "bucket_notification" {
  bucket = aws_s3_bucket.bucket.id
}

After

hcl
resource "aws_sns_topic" "topic" {
  name   = "s3-event-notification-topic"
  policy = data.aws_iam_policy_document.topic.json
}

resource "aws_s3_bucket" "bucket" {
  bucket = "your-bucket-name"
}

resource "aws_s3_bucket_notification" "bucket_notification" {
  bucket = aws_s3_bucket.bucket.id

  topic {
    topic_arn     = aws_sns_topic.topic.arn
    events        = ["s3:ObjectCreated:*"]
    filter_suffix = ".log"
  }
}

The first configuration has no destination. To verify the second, create a test object with a .log suffix and check that the subscriber receives its creation event. Deletions and other suffixes are outside this rule.

References