0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

DynamoDB Local

Posted at

概要

DynamoDB をローカル環境で利用する

https://github.com/idenrai/templates/tree/main/dynamodb_local

詳細

準備

Docker

Docker Desktop インストール

https://docs.docker.com/desktop/install/mac-install/

AWS

AWS-CLI

https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html

boto3
pip install boto3

https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html

Configure

円滑な利用のため、AWS Credentials 設定が必要

aws configure

以下のように設定

$ aws configure
AWS Access Key ID [None]: dummy
AWS Secret Access Key [None]: dummy
Default region name [None]: ap-northeast-1
Default output format [None]: json

手動設定の場合は以下になる

touch ~/.aws/credentials
vi ~/.aws/credentials
[default]
aws_access_key_id = dummy
aws_secret_access_key = dummy
touch ~/.aws/config
vi ~/.aws/config
[default]
region = ap-northeast-1
output = json

Code

以下の2つを利用

amazon/dynamodb-local
aaronshaf/dynamodb-admin

docker-compose.yml

version: "3.8"
services:
  dynamodb-local:
    command: "-jar DynamoDBLocal.jar -sharedDb -dbPath ./data"
    image: "amazon/dynamodb-local:latest"
    container_name: dynamodb-local
    ports:
      - "8000:8000"
    volumes:
      - "./docker/dynamodb:/home/dynamodblocal/data"
    working_dir: /home/dynamodblocal

  dynamodb-admin:
    container_name: dynamodb-admin
    image: aaronshaf/dynamodb-admin:latest
    environment:
      DYNAMO_ENDPOINT: dynamodb-local:8000
    ports:
      - "8001:8001"
    depends_on:
      - dynamodb-local

Run

docker-compose up

Test

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

以下のように出力されたら OK

$ aws dynamodb list-tables --endpoint-url http://localhost:8000
{
    "TableNames": []
}

GUI

8000 で DynamoDB を, 8001 で GUI を起動するので、GUI からも確認可能

http://localhost:8001/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?