How to set event S3 "Send to SQS queue"?

aws

#1

I want to setup a S3 Bucket event for ObjectCreate (All) to send to a SQS queue (not to trigger the Lambda directly). To set the Lambda in Serverless.yml I would:

  - s3:
      bucket: ${self:custom.secrets.S3_INBOUND_EINVOICE}
      event: s3:ObjectCreated:*

Where can I add “Send to SQS”?


#2

In theory (didn’t try it myself yet) you create the queue and the bucket as a separate resources under resources: and configure S3 to send events to the queue. Something along the lines of

resources:
  Resources:
    DestinationQueue:
      [...]
    SourceBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: SourceBucket
        NotificationConfiguration:
          QueueConfigurations:
            - Event: s3:ObjectCreated:*
              Queue: {"Ref": "DestinationQueue"}

Then you hook your Lambda to the queue according to the fine manual https://serverless.com/framework/docs/providers/aws/events/sqs/