[SOLVED] Multiple SNS notofications to a single S3 bucket

I have the following resource:

Resources:
  UploadBucket:
    DependsOn: UploadTopic
    Type: AWS::S3::Bucket
    Properties:
      VersioningConfiguration:
        Status: "Enabled"
      NotificationConfiguration:
        TopicConfigurations:
          - Event: s3:ObjectCreated:*
            Topic:
              Ref: UploadTopic
            Filter:
              S3Key:
                Rules:
                  - Name: prefix
                    Value: uploads/
          # - Event: s3:ObjectCreated:*
          #   Topic:
          #     Ref: ProcessUploadTopic
          #   Filter:
          #     S3Key:
          #       Rules:
          #         - Name: prefix
          #           Value: process/
  UploadBucketPolicy:
    DependsOn: UploadBucket
    Type: AWS::S3::BucketPolicy
    Properties:
      Bucket:
        Ref: UploadBucket
      PolicyDocument:
        Statement:
          - Action:
              - s3:putObject
            Effect: "Allow"
            Principal:
              "AWS":
                - "arn:aws:iam::#{AWS::AccountId}:root"
            Resource:
              - Fn::Join:
                - ''
                - - 'arn:aws:s3:::'
                  - Ref: UploadBucket
                  - '/*.csv'
              - Fn::Join:
                - ''
                - - 'arn:aws:s3:::'
                  - Ref: UploadBucket
                  - '/.tsv'
              - Fn::Join:
                - ''
                - - 'arn:aws:s3:::'
                  - Ref: UploadBucket
                  - '/.txt'

Outputs:
  UploadBucket:
    Value:
      Fn::GetAtt:
        - "UploadBucket"
        - "Arn"

if i enable the ProcessUploadTopic i get:

  Serverless Error ---------------------------------------
 
  An error occurred: UploadBucket - Unable to validate the following destination configurations (Service: Amazon S3; Status Code: 400; Error Code: InvalidArgument; Request ID: DD7F6DFEC6A6686B; S3 Extended Request ID: dHVmbYzf2LvpF3tswWujuhY4AAOr3D6/cMV8+VMFA7pKuKHXNp32Y6gcbsKUPdn0ji+SfOm15hc=).

i tried adding DepondsOn, as:

Resources:
  UploadBucket:
    DependsOn:
    - "UploadTopic"
    - "ProcessUploadTopic"
    Type: AWS::S3::Bucket
    Properties:
      VersioningConfiguration:
        Status: "Enabled"
      NotificationConfiguration:
        TopicConfigurations:
          - Event: s3:ObjectCreated:*
            Topic:
              Ref: UploadTopic
            Filter:
              S3Key:
                Rules:
                  - Name: prefix
                    Value: uploads/
          - Event: s3:ObjectCreated:*
            Topic:
              Ref: ProcessUploadTopic
            Filter:
              S3Key:
                Rules:
                  - Name: prefix
                    Value: process/
  ...

but even this fails.

what is the correct way to add separate SNS notifications based on where the object was created?

i had to add the TopicPolicy, as:

  ProcessUploadTopicPolicy:
    Type: AWS::SNS::TopicPolicy
    Properties:
      PolicyDocument:
        Version: '2012-10-17'
        Statement:
        - Sid: AllowUploadBucketToPushNotificationEffect
          Effect: Allow
          Principal:
            Service: s3.amazonaws.com
          Action: sns:Publish
          Resource: "*"
      Topics:
      - Ref: ProcessUploadTopic