Setting Up DynamoDB locally
The Docker version of DynamoDB lets you write and test applications without AWS account. As a DevOps, one should provide a similar Development environment to each developer as running in production which is the end goal of every DevOps Team. Another advantage is, you can run without connecting AWS every time and save cost as well. When you're ready to deploy your application in production, you just need to change the Endpoint in your code so that it uses the DynamoDB web service.
I assume that the Docker is already installed, All you have to run this command and that's it.
docker run -p 8000:8000 amazon/dynamodb-local
But, The issue with the above docker image is, you can't change the port from `8000` thousand which is sometimes required in the development environment. And it's really hard to override the Entry point or change anything as per your need in AWS services.
So this section is the backbone of this article, as our requirement is starting Dynamo DB some other port then `8000`. Here I am going run container using port `8003`, but keep in mind that base image is still AWS offical image, you can create one but its again required effort to keep it up to date.
DockerFile:
FROM amazon/dynamodb-local WORKDIR /home/dynamodblocal
ENTRYPOINT ["java", "-jar", "DynamoDBLocal.jar", "-port", "8003"]
Now you are good to go to build the Docker.
docker build -t mydynamodb .
Run the Container
docker run -dit --name mydynamodb mydynamodb
Once the Dynamo DB is up, You will be able to see the logs and the port that is 8003.
NodeJS | Serverless | AWS | Terraform | Docker
5 年really helpful, thanks (y)
Great post man!! love the memes you post in-between haha