amazon-web-servicesdockeramazon-sqslocalstack

How can I check an AWS SQS queue is available before accessing it?


I am implementing a LocalStack SQS using Docker in my project and my server fails when the queue has not been created.

I did some research and found that we can add a health check for other containers. But to add healthcheck.

How can I check if the queue has successfully created?

After only the healthcheck is successful, it should start the main container.


Solution

  • SQS wasn't really designed for the use case of dynamic queues. One way is to test to see if the queue exists with something like this:

    #!/bin/bash
    until aws sqs get-queue-url --queue-name bob; do
      sleep 10
    done