Deploying DynamoDB Locally on Your Computer - Amazon DynamoDB

Deploying DynamoDB Locally on Your Computer

Download Locally

The downloadable version of Amazon DynamoDB is provided as an executable .jar file. The application runs on Windows, Linux, macOS, and other platforms that support Java.

Follow these steps to set up and run DynamoDB on your computer.

To set up DynamoDB on your computer

  1. Download DynamoDB for free using one of the following links.

    Region Download Links Checksums

    Asia Pacific (Mumbai) Region

    .tar.gz | .zip

    .tar.gz.sha256 | .zip.sha256

    Asia Pacific (Singapore) Region

    .tar.gz | .zip

    .tar.gz.sha256 | .zip.sha256

    Asia Pacific (Tokyo) Region

    .tar.gz | .zip

    .tar.gz.sha256 | .zip.sha256

    Europe (Frankfurt) Region

    .tar.gz | .zip

    .tar.gz.sha256 | .zip.sha256

    South America (São Paulo) Region

    .tar.gz | .zip

    .tar.gz.sha256 | .zip.sha256

    US West (Oregon) Region

    .tar.gz | .zip

    .tar.gz.sha256 | .zip.sha256

    DynamoDB is also available as part of the AWS Toolkit for Eclipse. For more information, see AWS Toolkit For Eclipse.

    Important

    To run DynamoDB on your computer, you must have the Java Runtime Environment (JRE) version 6.x or newer. The application doesn't run on earlier JRE versions.

  2. After you download the archive, extract the contents and copy the extracted directory to a location of your choice.

  3. To start DynamoDB on your computer, open a command prompt window, navigate to the directory where you extracted DynamoDBLocal.jar, and enter the following command.

    java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
    Note

    If you're using Windows PowerShell, be sure to enclose the parameter name or the entire name and value like this:

    java -D"java.library.path=./DynamoDBLocal_lib" -jar DynamoDBLocal.jar

    DynamoDB processes incoming requests until you stop it. To stop DynamoDB, press Ctrl+C at the command prompt.

    DynamoDB uses port 8000 by default. If port 8000 is unavailable, this command throws an exception. For a complete list of DynamoDB runtime options, including -port, enter this command.

    java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -help

  4. Before you can access DynamoDB programmatically or through the AWS Command Line Interface (AWS CLI), you must configure your credentials to enable authorization for your applications. Downloadable DynamoDB requires any credentials to work, as shown in the following example.

    AWS Access Key ID: "fakeMyKeyId" AWS Secret Access Key: "fakeSecretAccessKey"

    You can use the aws configure command of the AWS CLI to set up credentials. For more information, see Using the AWS CLI.

  5. Start writing applications. To access DynamoDB running locally with the AWS CLI, use the --endpoint-url parameter. For example, use the following command to list DynamoDB tables.

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

Follow these steps to use Amazon DynamoDB in your application as a dependency.

To deploy DynamoDB as an Apache Maven repository

  1. Download and install Apache Maven. For more information, see Downloading Apache Maven and Installing Apache Maven.

  2. Add the DynamoDB Maven repository to your application's Project Object Model (POM) file.

    <!--Dependency:--> <dependencies> <dependency> <groupId>com.amazonaws</groupId> <artifactId>DynamoDBLocal</artifactId> <version>[1.12,2.0)</version> </dependency> </dependencies> <!--Custom repository:--> <repositories> <repository> <id>dynamodb-local-oregon</id> <name>DynamoDB Local Release Repository</name> <url>https://s3-us-west-2.amazonaws.com/dynamodb-local/release</url> </repository> </repositories>
    Note

    You can also use one of the following repository URLs, depending on your AWS Region.

    id Repository URL

    dynamodb-local-mumbai

    https://s3.ap-south-1.amazonaws.com/dynamodb-local-mumbai/release

    dynamodb-local-singapore

    https://s3.ap-southeast-1.amazonaws.com/dynamodb-local-singapore/release

    dynamodb-local-tokyo

    https://s3.ap-northeast-1.amazonaws.com/dynamodb-local-tokyo/release

    dynamodb-local-frankfurt

    https://s3.eu-central-1.amazonaws.com/dynamodb-local-frankfurt/release

    dynamodb-local-sao-paulo

    https://s3.sa-east-1.amazonaws.com/dynamodb-local-sao-paulo/release

The aws-dynamodb-examples repository in GitHub contains examples for starting and stopping DynamoDB local inside a Java program and using DynamoDB local in JUnit tests.

Docker

The downloadable version of Amazon DynamoDB is available as a Docker image. For more information, see dynamodb-local.

For an example of using DynamoDB local as part of a REST application built on the AWS Serverless Application Model (AWS SAM), see SAM DynamoDB application for managing orders. This sample application demonstrates how to use DynamoDB local for testing.

If you want to run a multi-container application that also uses the DynamoDB local container, use Docker Compose to define and run all the services in your application, including DynamoDB local.

To install and run DynamoDB local with Docker Compose:

  1. Download and install Docker Desktop.

  2. Copy the following code to a file and save it as docker-compose.yml

    version: '3.7' services: dynamodb-local: image: amazon/dynamodb-local:latest container_name: dynamodb-local ports: - "8000:8000"

    if you want to have your application and DynamoDB local be in separate containers use the following yaml file:

    version: '3.7' services: dynamodb-local: image: amazon/dynamodb-local container_name: dynamodb-local ports: - "8000:8000" app-node: depends_on: - dynamodb-local image: banst/awscli container_name: app-node ports: - "8080:8080" environment: AWS_ACCESS_KEY_ID: 'DUMMYIDEXAMPLE' AWS_SECRET_ACCESS_KEY: 'DUMMYEXAMPLEKEY' command: dynamodb describe-limits --endpoint-url http://dynamodb-local:8000 --region us-west-2

    This docker-compose.yml script creates an app-node container and a dynamodb-local container. The script runs a command in the app-node container that uses the AWS CLI to connect to the dynamodb-local container and describes the account and table limits.

    To use with your own application image, replace the image value in the example below with that of your application's:

    version: '3.7' services: app-node: image: location-of-your-dynamodb-demo-app:latest container_name: app-node ports: - "8080:8080" depends_on: - "dynamodb-local" links: - "dynamodb-local" environment: - AWS_ACCESS_KEY_ID='DUMMYIDEXAMPLE' - AWS_SECRET_ACCESS_KEY='DUMMYEXAMPLEKEY' - REGION='eu-west-1' dynamodb-local: image: amazon/dynamodb-local:latest container_name: dynamodb-local ports: - "8000:8000"
    Note

    The yaml scripts require that you specify an AWS access key and an AWS secret key, but they are not required to be valid AWS keys for you to access DynamoDB local.

  3. Run the following command-line:

    docker-compose up