# \[SOLVED\] Multiple SNS notofications to a single S3 bucket

**URL:** <https://forum.serverless.com/t/solved-multiple-sns-notofications-to-a-single-s3-bucket/7664>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [March 13, 2019, 8:10pm UTC](https://forum.serverless.com/t/solved-multiple-sns-notofications-to-a-single-s3-bucket/7664 "2019-03-13T20:10:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![khinester](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/khinester/32/315_2.png) [@khinester](https://forum.serverless.com/u/khinester)\
**Post date:** [March 13, 2019, 8:10pm UTC](https://forum.serverless.com/t/solved-multiple-sns-notofications-to-a-single-s3-bucket/7664/1 "2019-03-13T20:10:20Z")

</div>

I have the following resource:

```auto
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:

```auto
  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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![khinester](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/khinester/32/315_2.png) [@khinester](https://forum.serverless.com/u/khinester)\
**Post date:** [March 13, 2019, 8:25pm UTC](https://forum.serverless.com/t/solved-multiple-sns-notofications-to-a-single-s3-bucket/7664/2 "2019-03-13T20:25:27Z")

</div>

i had to add the TopicPolicy, as:

```auto
  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

```
