首页 > 解决方案 > 我可以在 TopicConfiguration 上为具有 OR 条件的 cloudformation s3 存储桶创建过滤器规则吗

问题描述

为了不重复代码,我希望能够创建一个带有 OR 条件的过滤器规则......如果任一条件为真,则满足过滤器。

这是我想避免的原始方式。

MyBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: myBuck

      NotificationConfiguration:        
        TopicConfigurations:
          - Event: 's3:ObjectCreated:*'         
            Filter:
              S3Key:
                Rules:
                  - Name: prefix
                    Value: data/abcd/                                  
            Topic: myTopicArnGoesHere
          - Event: 's3:ObjectCreated:*'         
            Filter:
              S3Key:
                Rules:
                  - Name: prefix
                    Value: data/efgh/  
            Topic: myTopicArnGoesHere

相反,我希望有办法做这样的事情

NewBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: myBuck
      VersioningConfiguration:
        Status: Enabled
      NotificationConfiguration:        
        TopicConfigurations:
          - Event: 's3:ObjectCreated:*'         
            Filter:
              S3Key:
                Rules:
                  - Name: prefix
                    Value: data/abcd/                                  
                  OR
                  - Name: prefix
                    Value: data/efgh/                                  
            Topic: myTopicArnGoesHere


标签: amazon-web-servicesamazon-s3amazon-cloudformation

解决方案


推荐阅读