amazon-web-servicesdnsamazon-sqslocalstack

Localstack upgrade v2 -> v3 - SQS service not available on localhost


I have a Localstack repository which starts up using Docker Compose. The relevant part of the Docker Compose file is as follows:

version: '3.4'
services:
  localstack:
    image: localstack/localstack:2.3.2
    environment:
      - SERVICES=dynamodb,kinesis,s3,sns,sqs
      - DEFAULT_REGION=eu-west-1
      - HOSTNAME_EXTERNAL=${DEV_HOST:-host.docker.internal}
      - LOCALSTACK_SSL=0
      - REQUESTS_CA_BUNDLE=
      - CURL_CA_BUNDLE=
    ports:
      - 4566:4566
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:4566/health" ]
      interval: 30s
      timeout: 10s
      retries: 5

I am upgrading the Localstack version stepwise and I want to go to 3.0.1

As part of the Localstack repo, SQS Queues are created and these are then accessed on localhost.

The queues can be listed from the command line using AWS CLI as follows:

$ aws sqs list-queues --endpoint-url http://localhost:4566  # (1)

And they can be accessed directly on localhost on my (Windows) machine using

http://localhost:4566/000000000000?Action=ListQueues  # (2)

After upgrading to 3.0.1 the queues are still visible using AWS CLI (1) but they are no longer accessible directly on localhost (2).

I have been through the Localstack documentation and tried many different configuration changes to make the SQS queues accessible over localhost as before but nothing works.


Solution

  • (answering my own question)

    The fix to the above was as follows:

    (i) replace HOSTNAME_EXTERNAL with LOCALSTACK_HOST and add a new setting to set the Sqs Endpoint Strategy to "dynamic" as follows:

    version: '3.4'
    services:
      localstack:
        image: localstack/localstack:3.2.0
        environment:
          - SERVICES=dynamodb,kinesis,s3,sns,sqs
          - DEFAULT_REGION=eu-west-1
          - SQS_ENDPOINT_STRATEGY=dynamic
          - LOCALSTACK_HOST=127.0.0.1
          - LOCALSTACK_SSL=0
          - REQUESTS_CA_BUNDLE=
          - CURL_CA_BUNDLE=
        ports:
          - 4566:4566
        healthcheck:
          test: [ "CMD", "curl", "-f", "http://localhost:4566/health" ]
          interval: 30s
          timeout: 10s
          retries: 5
    

    (ii) As the dynamic endpoint strategy was added in 3.2.0, I needed to go to 3.2.0 rather than 3.0.1 as I was originally intending

    (iii) The URL format for accessing the queues has changed .
    Previously I was using

    http://localhost:4566/000000000000/[queueName]?Action=ReceiveMessage

    and I have now had to change this to

    http://localhost:4566/queue/[region]/000000000000/[queueName]?Action=ReceiveMessage

    where [queueName] and [region] should be replaced as appropriate but the "queue" after the localhost address is actually the word "queue"