0

I wanted to test a container locally before pushing it to aws ecs.

I ran unit tests against a docker-compose stack including a dynamodb-local container using a Go (aws-sdk-go-v2) endpoint resolver with http://localhost:8000 as the url.

So I wanted to build and test container locally and realised I needed to attach it to the default network created by docker-compose. I struggled with this a bit so I build a stripped down trial. I created an endpoint resolver with a url of http://dynamo-local:8000 (named the container dynamo-local in d-c) and attached it to the default network within docker run.

Now that all works, I can perform the various table operations successfully, but one of the things that confuses me is that if I run aws cli:

aws --endpoint-url=http://localhost:8000 dynamodb list-tables

then the output shows no tables exist when there is definitely a table existing. I had assumed, naively, that as I can access port 8000 of the same container with different endpoints I should be able to access the same resources. Wrong.

Obviously a gap in my education. What am I missing ? I need to expand the trial to a proper test of the full app, so its important to me that I understand what is going on here.

Is there a way I can use the aws cli to access the table?

docker-compose file :

version: '3.5'
services:
  localstack:
    image: localstack/localstack:latest
    container_name: localstack_test
    ports:
      - '4566:4566'
    environment:
      - SERVICES=s3,sns,sqs, lambda
      - DEBUG=1
      - DATA_DIR=
    volumes:
      - './.AWSServices:/tmp/AWSServices'
      - '/var/run/docker.sock:/var/run/docker.sock'

  nginx:
    build:
      context: .
      dockerfile: Dockerfile
    image: chanonry/urlfiles-nginx:latest
    container_name: nginx
    ports:
      - '8080:80'

  dynamodb:
    image: amazon/dynamodb-local:1.13.6
    container_name: dynamo-local
    ports:
      - '8000:8000'


networks:
  default:
    name: test-net
Chanonry
  • 423
  • 7
  • 19

0 Answers0