CoorpAcademy / serverless-plugins

Collection of serverless plugins :zap:
231 stars 131 forks source link

configuring sqs #160

Open someone-1 opened 3 years ago

someone-1 commented 3 years ago

https://github.com/CoorpAcademy/serverless-plugins/tree/master/packages/serverless-offline-sqs#how-it-works

I am not able to follow the documentation

the example URL is hitting 404 https://github.com/CoorpAcademy/serverless-plugins/blob/master/packages/serverless-offline-sqs-integration/docker-compose.yml

could someone advise how on how to setup sqs locally

nathanielrindlaub commented 3 years ago

Agreed - fixing that example link would be super helpful.

larrybotha commented 3 years ago

The docker-compose.yml in the project root may be useful: https://github.com/CoorpAcademy/serverless-plugins/blob/master/docker-compose.yml#L13

colesiegel commented 2 years ago

I'm wondering the same. The docs mention some initialization script to create the queues, but I can't seem to find it anywhere. I've set autoCreate to true but my calls to SQS fail with AWS.SimpleQueueService.NonExistentQueue

Do I need to manually create all the queues in ElasticMQ, even though I have defined them in the serverless configuration?

dirtyRuby commented 2 years ago

@colesiegel I'm not sure what actually helped, for me is seems that for autocreation you need both SQS Queue and some event handler defined, which uses this queue. Also i made sure that both ElasticMQ conf and serverless-offline-sqs have same accountId and region configuration.

provider:
  region: us-west-1
custom:
  serverless-offline-sqs:
    autoCreate: true
    apiVersion: '2012-11-05'
    endpoint: 'http://0.0.0.0:9324'
    region: ${self:provider.region}
    accessKeyId: root
    secretAccessKey: root
    skipCacheInvalidation: false
    accountId: 123456789012
resources:
  Resourses:
    TestQueue:
      Type: AWS::SQS::Queue
      Properties:
        DelaySeconds: 0
        VisibilityTimeout: 300
        QueueName: ${self:service}-${self:custom.stage}-test-queue
functions:
  test-sqs-handler:
    ...
    events:
      - sqs:
          batchSize: 10
          queueName: ${self:resources.Resources.TestQueue.Properties.QueueName}

# elasticmq.conf
...
aws {
    region = us-west-1
    accountId = 123456789012
}
reidkersey commented 1 year ago

For others coming here in search of issues with NonExistentQueue. Make sure you have your plugins section ordered properly.

serverless-offline-sqs must come BEFORE serverless-offline