-
Notifications
You must be signed in to change notification settings - Fork 18
Local Dev ‐ Dynamo
This setup guide is for running local dynamo from zip files.
Try running, java -version
on your commandline. If you have java runtime environment set up, you should see something like this below:
$ java -version
java version "1.8.0_361"
Java(TM) SE Runtime Environment (build 1.8.0_361-b09)
If you don't, please go through the jre setup from here. Once the setup is complete and the path to java is in your PATH
environment variable, try running the above command. You should now be able to get the java version you are running.
You can download the files from here and extract them.
To start the local DynamoDB, navigate to the directory where you extracted DynamoDBLocal.jar and enter the following command:
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
Ensure that the AWS_ACCESS_KEY_ID
and the AWS_SECRET_ACCESS_KEY
environment variables are set up with fake values before requesting the local dynamo.
You can alternatively set up dynamo locally using docker with the guide provided here.
- It requires a local dynamo to be running. Please take a look at the section above for setting up local dynamo.
- aws CLI to be available. Please refer here to find relevant documentation.
-
jq package to be available. If
jq
is not already available, it will try to install it usingbrew
ormacPorts
. - env variable
AWS_PROFILE
set up with a profile name with access to the staging tables or other configured source tables.
The following environment variables can be set with values to override default values.
-
REMOTE_DYNAMO_PREFIX
can be configured to the prefix of the remote table to be used as the source when creating new tables. This defaults tostaging
. -
LOCAL_DYNAMO_PREFIX
can be configured to the prefix of the local dynamo table to be created. This defaults tolocal
. -
LOCAL_DYNAMO_PORT
can be configured to the port where the local dynamo is listening. This defaults to8000
.
The script takes the names of tables to be created as arguments.
To access the remote table, you may need to set your AWS_PROFILE
environment variable. Before running any of the below commands, make sure you run:
$ export AWS_PROFILE=sci-imaging
The script can be run from the command line as follows, from the folder where the script exists.
$ ./local-dynamo-setup.sh "install-activity"
This will create the table local-install-activity
if it doesn't already exist in the local dynamo.
This will also provide an option to backfill the local table with all the data present in the remote table.
Multiple table names can also be passed in a single invocation as follows:
$ ./local-dynamo-setup.sh plugin-metadata category
The following command should create all the tables needed for the backend application:
$ ./local-dynamo-setup.sh category plugin plugin-metadata plugin-blocked install-activity github-activity
When running locally, set up the LOCAL_DYNAMO_HOST
environment variable to http://localhost:8000
or where ever your local dynamo is running, and STACK_NAME
to local
or any other value configured using LOCAL_DYNAMO_PREFIX
Example:
$ export LOCAL_DYNAMO_HOST="http://localhost:8000"
$ export STACK_NAME="local"
In the pynamo models, set up the host attribute of the metaclass to get the value assigned to LOCAL_DYNAMO_HOST
environment variable. As done here.
For more information on using the AWS CLI, please click here.