I am using docker enabled dynamoDB local as mentioned here
and following is my JS code:
AWS.config.update({
region: 'sas',
endpoint: 'http://docker.for.mac.host.internal:8000' //'http://localhost:8000'
});
and create table function below:
function createTable() {
let params = {
TableName: 'sas',
KeySchema: [{
AttributeName: 'title',
KeyType: 'HASH',
}],
AttributeDefinitions: [{
AttributeName: 'title',
AttributeType: 'S'
}],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1,
}
};
dynamoDB.createTable(params, function(err, data) {
if (err)
console.log(err); // an error occurred
else
console.log(data);
});
}
i could see created table sas using cli :
aws dynamodb list-tables --endpoint-url http://localhost:8000 --region=sas
but NOT listing the table in the and it's always empty.
http://localhost:8000/shell/
any idea's?
NOTE: i can see my table with above code, by running dynamodb jar locally
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
As @Mendhak points out in the comments on another answer here, if you are using docker-compose, you will need to share the db, which you can do by overriding the command
in docker-compose.yml
version: "3.7"
services:
dynamodb-local:
image: amazon/dynamodb-local:latest
container_name: dynamodb-local
ports:
- "8000:8000"
command: -jar DynamoDBLocal.jar -sharedDb
I didn't see this anywhere in the sprawling AWS docs, so I wanted to leave this answer to improve visibility for other wandering devs.
Credit to Mendhak - you could upvote his comment as well as this answer, if it helped you!
You can specify -sharedDb param when start docker dynamodb.
docker run -itd -p 8000:8000 --name dev-db amazon/dynamodb-local:latest -jar DynamoDBLocal.jar -sharedDb
make sure you are also passing -sharedDb to the docker image.
If -sharedDb is not present then dynamodb-local will use
access keys+region as namespaces to separate tables
(as if they were under different aws accounts)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With