I've installed DynamoDB locally on my Mac (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html) and I've written a bash alias intending to avoid having to cd
into the DynamoDB directory and run
$ java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
every time I want to start the database. However, the alias doesn't seem to be working as expected...
First off, the alias that I've written is
alias ddb-start="java -Djava.library.path=~/Documents/dynamodb/DynamoDBLocal_lib -jar ~/Documents/dynamodb/DynamoDBLocal.jar -sharedDb"
and when I run $ ddb-start
, the database starts as expected:
Initializing DynamoDB Local with the following configuration:
Port: 8000
InMemory: false
DbPath: null
SharedDb: true
shouldDelayTransientStatuses: false
CorsParams: *
The problem is, unless I run the script from ~/Documents/dynamodb/
, all of my tables are missing.
So if I cd
to Documents/dynamodb/
and then run $ ddb-start
, everything is perfect. But if I open a new terminal window and run $ ddb-start
(or run it from anywhere other than Documents/dynamodb/
), Dynamo appears to start up as it should but when I list the tables in the JavaScript Shell, there are no tables.
I was hoping to be able to run the alias from any directory and have Dynamo start and run correctly. Must I cd
into the directory, even with an alias? Or is there something wrong with the alias that I've written?
*** Ah, I've noticed that, whatever directory I run it from, a copy of shared-local-instance.db
is created in that directory. I don't want that to happen, I want it to point at the 'original' shared-local-instance.db
in ~/Documents/dynamodb/
. How can I do that?
Figured it out - I was missing the -dbPath
option in my alias. To run the alias from anywhere, I needed to specify where the shared db is located. The working alias is:
alias ddb-start="java -Djava.library.path=~/Documents/dynamodb/DynamoDBLocal_lib -jar ~/Documents/dynamodb/DynamoDBLocal.jar -sharedDb -dbPath ~/Documents/dynamodb/"