dynamodb-admin not working with docker.compose.yml and localstack

Viewed 314

This is my docker_compose:

version: '3.7'
services:
  app:
    command: run
    build:
      context: .
      dockerfile: Dockerfile.dev
    image: test/testapi-configuration
    ports:
      - '5005:5005'
      - '8080:8080'
    volumes:
      - './:/source:rw'
      - '~/.vault_token:/root/.vault_token'
  localstack:
    image: localstack/localstack
    ports:
      - '4566:4566'
    environment:
      - SERVICES=dynamodb
      - DEBUG=1
      - DATA_DIR=/tmp/localstack/data
      - DEFAULT_REGION=us-east-2
    volumes:
      - './.localstack:/tmp/localstack'
      - '/var/run/docker.sock:/var/run/docker.sock'

My dockerfile.dev:

WORKDIR /source
ENTRYPOINT ["./gradlew"]
EXPOSE 5005

I set up my app running with:

localstack start

Then I run my api in the IntelliJ IDE, y create the table in the dynamoDb with:

aws dynamodb --endpoint-url=http://localhost:4566 --region=us-east-2 create-table --cli-input-json file://file_example.json

But I cant get to use the dynamodb-admin tool working. Docs here: https://www.npmjs.com/package/dynamodb-admin

I understand that I have to execute:

DYNAMO_ENDPOINT=http://localhost:8080 dynamodb-admin -p 4566

But ive got following error:

UnknownError: 405
    at Request.extractError (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/protocol/json.js:52:27)
    at Request.callListeners (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/request.js:686:14)
    at Request.transition (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/request.js:688:12)
    at Request.callListeners (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
1 Answers

The right way to do it was:

docker-compose up localstack
Related