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?