/dynamo-ocean

spring boot dynamodb POC

Primary LanguageJavaMIT LicenseMIT

dynamo-ocean

Sprinb Boot DynamoDB

A proof of concept to connect dynamodb and spring boot. It runs locally

Lessons Learned

Learned how to set up a local version of dynamodb, install the aws cli and how it connects with spring boot. Learned the hard way using aws cli with pws 7 and switched to bash.

Installation

Install with maven

    mvn clean install

Download Local Dynamodb

DynamoDB Link

Extract to Somewhere

Install AWS CLI

Run Locally

Recommended to use Git Bash

Navigate where you downloaded DynamoDB

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

Create a table

aws dynamodb create-table \
--table-name Stands \
--attribute-definitions \
AttributeName=id,AttributeType=S \
AttributeName=part,AttributeType=N \
--key-schema AttributeName=id,KeyType=HASH \
AttributeName=part,KeyType=RANGE \
--provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 --endpoint-url http://localhost:8000

The end part is important because we are running locally

List Tables

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

Delete Table

aws dynamodb delete-table --table-name Stands --endpoint-url http://localhost:8000

Add item

 aws dynamodb put-item \
    --table-name Stands \
    --item '{
      "name": {"S": "Golden Experience"},
	  "part":{"N":"3"}
    }' \
    --endpoint-url http://localhost:8000

Run Spring Boot

./mvnw spring-boot:run

License

MIT

Documentation

Documentation

Spring Boot