简体   繁体   中英

How to configure AWS SQS Queue to Listen already created S3 bucket's events

I have aws S3 bucket which is created by aws console. Now I want to deploy AWS SQS Queue for listening that bucket's object creating events with the Serverless framework.

Can someone explain how to achieve the task?

Here are relevant parts of my yml file:

......

iamRoleStatements:
    - Effect: Allow
      Action:
        - sqs:*
      Resource:
        - "*"
......

resources:
  Resources:
    PDFConverterQueue:
      Type: "AWS::SQS::Queue"
      Properties:
        QueueName: "PDFConverterQueue"

     #### How can I configure this Queue to listen to previously created bucket's events.
.....

You will probably have better success to have the Lambda be invoked directly by the S3 event. The S3 requests are asynchronous and have exponential retry policies in place in case of failure.

functions:
  pdfConverter:
    handler: handler.pdfconverted
    events:
      - s3:
          bucket: pdftoconvert 
          event: s3:ObjectCreated:*
          existing: true

No need for an SQS queue so you save some resources.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM