I'm new to CloudFormation and currently trying to send a S3:ObjectCreated to a specific SQS Queue.
The setup is in the Serverless Framework with Resources defined in CloudFormation. The problem is with the NotificationConfiguration with a QueueConfigurations that keeps giving error after error.
The syntax below seems to be correct when looking at the CloudFormation Designer online:
iamRoleStatements:
- Effect: Allow
Action:
- s3:ListBucket
Resource:
Fn::Join:
- ""
- - "arn:aws:s3:::"
- Ref: LabelBucket
- Effect: Allow
Action:
- s3:GetObject
- s3:PutObject
Resource:
Fn::Join:
- ""
- - "arn:aws:s3:::"
- Ref: LabelBucket
- "/*"
- Effect: Allow
Action:
- SQS:SendMessage
Resource:
Fn::Join:
- ""
- - "arn:aws:s3:::"
- Ref: LabelBucket
resources:
Resources:
LabelRequestQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: label-generate-request
LabelResponseQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: label-generate-response
LabelBucket:
Type: AWS::S3::Bucket
DependsOn:
- LabelResponseQueue
Properties:
BucketName: generation-bucket
NotificationConfiguration:
QueueConfigurations:
- Event: 's3:ObjectCreated:Put'
Queue: 'arn:aws:sqs:eu-west-1:539106611526:label-generate-response'
The exact error for this resource is:
An error occurred: CarrierLabelBucket - Unable to validate the following destination configurations (Service: Amazon S3; Status Code: 400; Error Code: InvalidArgument; Request ID: 12A3D93761EFFEAD; S3 Extended Request ID: Zfk2XKEKHhqtafaiFvrcpzyO8nHB6qOJs4gqJXpkOyhxSMgDTsUzZ0lQnYIrTEr2SVHhgMHw0ds=).
I have followed the instructions on the AWS docs to create the SNS topic first in a different deployment. You can find my working application config here:
https://github.com/drissamri/serverless-architecture/blob/master/infrastructure/serverless.yml
https://github.com/drissamri/serverless-architecture/blob/master/application/serverless.yml
If you are using Serverless Framework you can also use plugins that hide all the necessary configuration with a simplified config like https://www.npmjs.com/package/@agiledigital/serverless-sns-sqs-lambda