In my sls project, I setup sqs offline usage as shown below using this article.
- npm installed serverless-offline-sqs as dev dependency
- Included serverless-offline-sqs after serverless-offline in serverless.ts plugins section
- Added custom configuration for the Queue,
"serverless-offline-sqs": {
autoCreate: true,
apiVersion: "2012-11-05",
endpoint: "http://localhost:9324",
region: "us-east-1",
accessKeyId: "root",
secretAccessKey: "root",
skipCacheInvalidation: false,
},
- Included Queue resource in serverless.ts resources section:
FooQueue: {
Type: "AWS::SQS::Queue",
Properties: {
QueueName: "foo.fifo",
FifoQueue: true,
VisibilityTimeout: 60,
MessageRetentionPeriod: 345600,
},
},
- Running ElasticMQ docker
docker run -p 9324:9324 -p 9325:9325 softwaremill/elasticmq-native
- Started serverless offline sls offline start
Attempting to list Queues, does not display fifo.queue. Wondering why autoCreate is not creating the queue. List Queue action curl response:
curl "http://localhost:9324?Action=ListQueues"
<ListQueuesResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/">
<ListQueuesResult>
</ListQueuesResult>
<ResponseMetadata>
<RequestId>00000000-0000-0000-0000-000000000000</RequestId>
</ResponseMetadata>
</ListQueuesResponse>%
Wondering what am I missing to auto create the queue for offline mode? Offline start shows "offline: Starting Offline SQS: dev/us-east-1." message.
Versions:
"serverless-offline-sqs": "^6.0.0",
"serverless-offline": "^8.1.0",
Figured it out. Nothing wrong with plugin. Though I added lambda function handler for SQS events, I forgot to include the function in serverless.ts under "functions" resource. Including it in functions autoCreated the queue as expected.