一桶-多个主题AWS S3,SNS

时间:2019-07-16 00:29:40

标签: amazon-web-services amazon-s3 amazon-sns serverless-framework

我正在为一个存储桶事件尝试两个SNS主题。目前,我已经以这种方式配置了我的存储桶:

TranscribedBucket:
  Type: AWS::S3::Bucket
  DeletionPolicy: Retain
  Properties:
    NotificationConfiguration:
      TopicConfigurations:
        - Event: s3:ObjectCreated:*
          Topic:
            Ref: Transformer
          Filter:
            S3Key:
              Rules:
                - Name: prefix
                  Value: "transcribed-"
  BucketName: ${self:provider.transcribedBucket}

两个订户lambda正在监听主题Transfomer,它们实际上是在同一文件夹中的不同文件夹下输出的(例如,subscriberLambda1的folder1 / file1和subscriberLambda2的folder2 / file2)。完成此操作后,每当文件放入该文件夹时,我就会有一个lambda实际上需要消耗一个SNS事件。

由于- Event: s3:ObjectCreated:*无法复制,因此我实际上无法为同一存储桶再创建一个Topic。我该如何进行呢?

1 个答案:

答案 0 :(得分:1)

您应该能够执行以下操作:

TranscribedBucket:
  Type: AWS::S3::Bucket
  DeletionPolicy: Retain
  Properties:
    NotificationConfiguration:
      TopicConfigurations:
        - Event: s3:ObjectCreated:*
          Topic:
            Ref: Transformer
          Filter:
            S3Key:
              Rules:
                - Name: prefix
                  Value: "folder1/"
        - Event: s3:ObjectCreated:*
          Topic:
            Ref: Bumblebee
          Filter:
            S3Key:
              Rules:
                - Name: prefix
                  Value: "folder2/"
  BucketName: ${self:provider.transcribedBucket}