I Tried Filtering on the aws-generated-tags Added to S3 Event Notifications Using EventBridge

I Tried Filtering on the aws-generated-tags Added to S3 Event Notifications Using EventBridge

I tested the new aws-generated-tags in S3 event notifications on CloudFormation-created buckets. Filtering by stack name in EventBridge, Object Created events were captured from buckets added to the same stack without any rule changes.
2026.07.17

This page has been translated by machine translation. View original

Introduction

An aws-generated-tags field has been added to Amazon S3 event notifications. If a bucket has system-generated tags applied by an AWS service, those tags are now included in the event and can be used for filtering in EventBridge.

https://aws.amazon.com/about-aws/whats-new/2026/07/amazon-s3-event-notifications-system-generated-tags/

Aspect Before After the update
Information included in the event Bucket name, object key, size, etc. The above + aws-generated-tags (system-generated tags of the bucket)
Filtering method Listing bucket names individually Filtering by the tag values of aws-generated-tags (such as the stack name) is possible

I was curious about what is actually included, so I checked it with three patterns of buckets and also verified the filtering behavior in EventBridge.

https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-content-structure.html

Verification

Verification environment and configuration

I created three types of buckets and an EventBridge rule with the following CloudFormation template.

CloudFormation template excerpt (S3 bucket and EventBridge rule sections)
Resources:
  # Pattern 1: CFnシステムタグのみ(Tagsプロパティなし)
  BucketCfnTagsOnly:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: !Sub 's3-evt-verify-cfn-only-${Suffix}'
      NotificationConfiguration:
        EventBridgeConfiguration:
          EventBridgeEnabled: true

  # Pattern 2: ユーザー定義タグ付き
  BucketWithUserTags:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: !Sub 's3-evt-verify-user-tags-${Suffix}'
      NotificationConfiguration:
        EventBridgeConfiguration:
          EventBridgeEnabled: true
      Tags:
        - Key: Project
          Value: blog-verification
        - Key: Team
          Value: devio

  # Pattern 3: 手動タグ追加用(デプロイ後にput-bucket-tagging)
  BucketManualTag:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: !Sub 's3-evt-verify-manual-tag-${Suffix}'
      NotificationConfiguration:
        EventBridgeConfiguration:
          EventBridgeEnabled: true

  # aws-generated-tagsでフィルタリングするEventBridgeルール
  FilterRule:
    Type: AWS::Events::Rule
    Properties:
      Name: !Sub 's3-evt-verify-filter-rule-${Suffix}'
      State: ENABLED
      EventPattern:
        source:
          - aws.s3
        detail-type:
          - Object Created
        detail:
          bucket:
            aws-generated-tags:
              aws:cloudformation:stack-name:
                - s3-evt-awsgentags-verify
      Targets:
        - Id: FilterSQSTarget
          Arn: !GetAtt FilterQueue.Arn

  # FilterQueue (AWS::SQS::Queue) および QueuePolicy は省略

I created each of the three buckets with a different tag state and verified what is included in aws-generated-tags.

Pattern Bucket Tag state Verification point
1 BucketCfnTagsOnly Only aws:cloudformation:* (no Tags property) What goes into aws-generated-tags with system tags only
2 BucketWithUserTags aws:cloudformation:* + Project, Team (CFn Tags) Whether user-defined tags are included in aws-generated-tags
3 BucketManualTag aws:cloudformation:* + ManualTag (added manually) Whether manually added tags are included in aws-generated-tags

Contents of the aws-generated-tags field

I PUT an object to each pattern and compared the aws-generated-tags field of the received events.

Pattern Bucket tag state Tags included in aws-generated-tags
1. CFn system tags only Only aws:cloudformation:* aws:cloudformation:stack-name, stack-id, logical-id
2. With user-defined tags via CFn Tags aws:cloudformation:* + Project, Team aws:cloudformation:stack-name, stack-id, logical-id (Project and Team are not included)
3. Manually added tag aws:cloudformation:* + ManualTag aws:cloudformation:stack-name, stack-id, logical-id (ManualTag is not included)

For the CloudFormation-managed buckets verified this time, only the system-generated tags that CloudFormation applies were included in aws-generated-tags. Specifically, they are as follows.

  • Included: aws:cloudformation:stack-name, aws:cloudformation:stack-id, aws:cloudformation:logical-id
  • Not included: user tags defined in the Tags property of AWS::S3::Bucket, and tags manually added with put-bucket-tagging

In the pattern 1 event, aws-generated-tags contained the three CloudFormation system tags.

"bucket": {
  "name": "s3-evt-verify-cfn-only-20260717",
  "aws-generated-tags": {
    "aws:cloudformation:stack-id": "arn:aws:cloudformation:ap-northeast-1:123456789012:stack/s3-evt-awsgentags-verify/aa15e5b0-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "aws:cloudformation:logical-id": "BucketCfnTagsOnly",
    "aws:cloudformation:stack-name": "s3-evt-awsgentags-verify"
  }
}

In pattern 2, I had applied the Project and Team tags to the bucket, but the types of tag keys included in aws-generated-tags were the same as in pattern 1.

"bucket": {
  "name": "s3-evt-verify-user-tags-20260717",
  "aws-generated-tags": {
    "aws:cloudformation:stack-id": "arn:aws:cloudformation:ap-northeast-1:123456789012:stack/s3-evt-awsgentags-verify/aa15e5b0-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "aws:cloudformation:logical-id": "BucketWithUserTags",
    "aws:cloudformation:stack-name": "s3-evt-awsgentags-verify"
  }
}

In pattern 3 as well, I had manually added ManualTag with put-bucket-tagging, but the types of tag keys included in aws-generated-tags were the same as in patterns 1 and 2.

"bucket": {
  "name": "s3-evt-verify-manual-tag-20260717",
  "aws-generated-tags": {
    "aws:cloudformation:stack-id": "arn:aws:cloudformation:ap-northeast-1:123456789012:stack/s3-evt-awsgentags-verify/aa15e5b0-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "aws:cloudformation:logical-id": "BucketManualTag",
    "aws:cloudformation:stack-name": "s3-evt-awsgentags-verify"
  }
}
Full event JSON (Pattern 1: CFn system tags only)
{
  "version": "0",
  "id": "167f17bc-a5c7-74a0-b542-6f66e8007f69",
  "detail-type": "Object Created",
  "source": "aws.s3",
  "account": "123456789012",
  "time": "2026-07-16T19:46:12Z",
  "region": "ap-northeast-1",
  "resources": ["arn:aws:s3:::s3-evt-verify-cfn-only-20260717"],
  "detail": {
    "version": "0",
    "event-version": "1.1",
    "bucket": {
      "name": "s3-evt-verify-cfn-only-20260717",
      "aws-generated-tags": {
        "aws:cloudformation:stack-id": "arn:aws:cloudformation:ap-northeast-1:123456789012:stack/s3-evt-awsgentags-verify/aa15e5b0-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "aws:cloudformation:logical-id": "BucketCfnTagsOnly",
        "aws:cloudformation:stack-name": "s3-evt-awsgentags-verify"
      }
    },
    "object": {
      "key": "test-cfn-only.txt",
      "size": 14,
      "etag": "0c78c972ee4ad0cc767914a4a9235b55",
      "sequencer": "006A593504D0B0A5C4"
    },
    "request-id": "4E4R5T282H6KN86C",
    "requester": "123456789012",
    "source-ip-address": "203.0.113.1",
    "reason": "PutObject"
  }
}
Full event JSON (Pattern 2: With user-defined tags via CFn Tags)
{
  "version": "0",
  "id": "7ca7ec54-8fd1-daf6-562c-37b2940f5a86",
  "detail-type": "Object Created",
  "source": "aws.s3",
  "account": "123456789012",
  "time": "2026-07-16T19:46:13Z",
  "region": "ap-northeast-1",
  "resources": ["arn:aws:s3:::s3-evt-verify-user-tags-20260717"],
  "detail": {
    "version": "0",
    "event-version": "1.1",
    "bucket": {
      "name": "s3-evt-verify-user-tags-20260717",
      "aws-generated-tags": {
        "aws:cloudformation:stack-id": "arn:aws:cloudformation:ap-northeast-1:123456789012:stack/s3-evt-awsgentags-verify/aa15e5b0-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "aws:cloudformation:logical-id": "BucketWithUserTags",
        "aws:cloudformation:stack-name": "s3-evt-awsgentags-verify"
      }
    },
    "object": {
      "key": "test-user-tags.txt",
      "size": 15,
      "etag": "a9cd14919053d9c5045b54398d42009d",
      "sequencer": "006A5935054DC23AD2"
    },
    "request-id": "SZ06S3BAMTXTF0JH",
    "requester": "123456789012",
    "source-ip-address": "203.0.113.1",
    "reason": "PutObject"
  }
}
Full event JSON (Pattern 3: Manually added tag)
{
  "version": "0",
  "id": "f487191c-2aa0-397c-707c-3722670de533",
  "detail-type": "Object Created",
  "source": "aws.s3",
  "account": "123456789012",
  "time": "2026-07-16T19:46:13Z",
  "region": "ap-northeast-1",
  "resources": ["arn:aws:s3:::s3-evt-verify-manual-tag-20260717"],
  "detail": {
    "version": "0",
    "event-version": "1.1",
    "bucket": {
      "name": "s3-evt-verify-manual-tag-20260717",
      "aws-generated-tags": {
        "aws:cloudformation:stack-id": "arn:aws:cloudformation:ap-northeast-1:123456789012:stack/s3-evt-awsgentags-verify/aa15e5b0-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "aws:cloudformation:logical-id": "BucketManualTag",
        "aws:cloudformation:stack-name": "s3-evt-awsgentags-verify"
      }
    },
    "object": {
      "key": "test-manual-tag.txt",
      "size": 16,
      "etag": "975330f671d4c7fae808cf1e95a901ef",
      "sequencer": "006A593505C645201C"
    },
    "request-id": "SZ03VKFY5AY8DXSV",
    "requester": "123456789012",
    "source-ip-address": "203.0.113.1",
    "reason": "PutObject"
  }
}

Stack-name-based filtering in EventBridge

Using aws-generated-tags, I set up an EventBridge rule that captures only events from buckets created by a specific CloudFormation stack. The field name is in kebab-case (aws-generated-tags), and it is placed under detail.bucket rather than at the top level of the event. Therefore, in the event pattern, you specify it with the path detail.bucket.aws-generated-tags.

{
  "source": ["aws.s3"],
  "detail-type": ["Object Created"],
  "detail": {
    "bucket": {
      "aws-generated-tags": {
        "aws:cloudformation:stack-name": ["s3-evt-awsgentags-verify"]
      }
    }
  }
}

I ran three tests with this rule. In test 2, I added a new bucket (BucketNewAdded) with EventBridge notifications enabled to the same stack, deployed the stack update, and checked whether the event would be captured without changing the EventBridge rule.

Test Operation Expectation Result
1. PUT to a bucket in the stack PUT filter-v2-test1.txt to BucketCfnTagsOnly Reaches the filtering queue ✅ PASS
2. PUT to a newly added bucket (no rule change) PUT filter-v2-test2.txt to BucketNewAdded Reaches the filtering queue ✅ PASS
3. PUT to a bucket outside the stack (no CFn tags) PUT external-test.txt to an external bucket Does not reach the filtering queue ✅ PASS

If you add a bucket with EventBridge notifications enabled to the same stack, the events of that bucket can also be captured without changing the rule.

Summary

Using aws-generated-tags, you can filter S3 events by CloudFormation stack rather than by bucket name.

In a configuration where multiple S3 buckets are managed in the same stack and their Object Created events are aggregated to a common destination, using the stack name as the condition keeps the rule simple. In this verification, even when a bucket with EventBridge notifications enabled was added to the same stack, the events were captured without changing the EventBridge rule. This is useful for stacks where buckets are expected to be added and you want to reduce the individual management of bucket names.

Share this article

AWSのお困り事はクラスメソッドへ