Localstack: which port to use for ES rest api

Viewed 7004

I am using docker to run Localstack and image 0.11.1. I turned on es service and exposed port 4566 - as according to the doc (https://github.com/localstack/localstack):

Starting with version 0.11.0, all APIs are exposed via a single edge service, which is accessible on http://localhost:4566 by default

I could successfully use AWS CLI to list domain names and create ones:

aws --endpoint-url=http://localhost:4566 es list-domain-names
aws --endpoint-url=http://localhost:4566 es create-elasticsearch-domain --domain-name my-domain --elasticsearch-version 7.4

But when I tried to index document

curl -XPUT http://localhost:4566/my-domain/_doc/1 -d '{"hello": "World"}' -H 'Content-Type: application/json'

it returned {"status": "running"} reponse to me and I saw the message in logs:

INFO:localstack.services.edge: Unable to find forwarding rule for host "localhost:4566", path "/my-domain/_doc/1", target header "", auth header ""

Then I added port 4571 to exposed ports by configuring it in docker-compose.yml and tried the same, but using http://localhost:4571/my-domain/_doc/1 url this time to index document.

curl -XPUT http://localhost:4571/my-domain/_doc/1 -d '{"hello": "World"}' -H 'Content-Type: application/json'

It worked.

I don't understand - according to the doc I should only use port 4566 but it does not work. Am I missing something?


My docker-compose.yml with both ports exposed:

...
localstack:
    container_name: "localstack"
    image: localstack/localstack:0.11.1
    privileged: true
    ports:
      - "4566:4566"
      - "4571:4571"
    environment:
      - SERVICES=es
      - START_WEB=0
      - LAMBDA_REMOTE_DOCKER=0
      - DATA_DIR=/tmp/localstack/data
...
1 Answers

From here, you can see this table:

Parameter Description Default
service.edgePort Port number for Localstack edge service 4566
service.esPort Port number for Localstack elasticsearch service 4571
Related