본문 바로가기
AWS

DynamoDB

by DOSGamer 2022. 8. 24.
반응형

DynamoDB 설치방법

(일반) DynamoDB Local 설치

https://docs.aws.amazon.com/ko_kr/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html

폴더에 압축해제 (실행시에 JRE 필수)

인증처리

DynamoDB 에서 사용하는 가상 Fake 인증 ID 등록

# aws configure
AWS Access Key ID [None]: fakeMyKeyId
AWS Secret Access Key [None]: fakeSecretAccessKey

local dynamodb 실행과 종료 용 batch 파일 생성

#dbstart.bat
cd D:\studyspace\dynamodb
start javaw -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb

#dbstop.bat
for /f "tokens=5" %%p in (' netstat -ano ^| find "LISTENING" ^| find "8000" ') do taskkill /F /PID %%p

DB 확인

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

DynamoDB Client Tool 설치

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/workbench.settingup.html

(서버리스 프레임워크) plugin 으로 설치

99xt/serverless-dynamodb-local
Serverless Dynamodb Local Plugin - Allows to run dynamodb locally for serverless - 99xt/serverless-dynamodb-local
https://github.com/99xt/serverless-dynamodb-local
npm install --save serverless-dynamodb-local

serverless.yml 파일에 plugin 추가

plugins:
  - serverless-dynamodb-local

사용법

서버리스 프레임워크를 이용해서 dynamodb 설치

서버리스 프레임워크 설정 파일에서 dynamodb 세팅하고

migrate 옵션으로 설정 파일의 테이블과 인덱스를 생성하고 Dynamodb 실행

  1. Install DynamoDB Local sls dynamodb install
  1. Add DynamoDB Resource definitions to your Serverless configuration, as defined here: https://serverless.com/framework/docs/providers/aws/guide/resources/#configuration
  1. Start DynamoDB Local and migrate (DynamoDB will process incoming requests until you stop it. To stop DynamoDB, type Ctrl+C in the command prompt window). Make sure above command is executed before this. sls dynamodb start --migrate
--port  		  -p  Port to listen on. Default: 8000
--cors                    -c  Enable CORS support (cross-origin resource sharing) for JavaScript. You must provide a comma-separated "allow" list of specific domains. The default setting for -cors is an asterisk (*), which allows public access.
--inMemory                -i  DynamoDB; will run in memory, instead of using a database file. When you stop DynamoDB;, none of the data will be saved. Note that you cannot specify both -dbPath and -inMemory at once.
--dbPath                  -d  The directory where DynamoDB will write its database file. If you do not specify this option, the file will be written to the current directory. Note that you cannot specify both -dbPath and -inMemory at once. For the path, current working directory is <projectroot>/node_modules/serverless-dynamodb-local/dynamob. For example to create <projectroot>/node_modules/serverless-dynamodb-local/dynamob/<mypath> you should specify -d <mypath>/ or --dbPath <mypath>/ with a forwardslash at the end.
--sharedDb                -h  DynamoDB will use a single database file, instead of using separate files for each credential and region. If you specify -sharedDb, all DynamoDB clients will interact with the same set of tables regardless of their region and credential configuration.
--delayTransientStatuses  -t  Causes DynamoDB to introduce delays for certain operations. DynamoDB can perform some tasks almost instantaneously, such as create/update/delete operations on tables and indexes; however, the actual DynamoDB service requires more time for these tasks. Setting this parameter helps DynamoDB simulate the behavior of the Amazon DynamoDB web service more closely. (Currently, this parameter introduces delays only for global secondary indexes that are in either CREATING or DELETING status.)
--optimizeDbBeforeStartup -o  Optimizes the underlying database tables before starting up DynamoDB on your computer. You must also specify -dbPath when you use this parameter.
--migration               -m  After starting dynamodb local, run dynamodb migrations.
--heapInitial                 The initial heap size
--heapMax                     The maximum heap size
--migrate                 -m  After starting DynamoDB local, create DynamoDB tables from the Serverless configuration.
--seed                    -s  After starting and migrating dynamodb local, injects seed data into your tables. The --seed option determines which data categories to onload.
--convertEmptyValues      -e  Set to true if you would like the document client to convert empty values (0-length strings, binary buffers, and sets) to be converted to NULL types when persisting to DynamoDB.


Uploaded by N2T

반응형

'AWS' 카테고리의 다른 글

puppeteer + lambda 조합으로 사용법  (0) 2022.08.26
IAM 정책  (0) 2022.08.24
Underneath DynamoDB  (0) 2022.08.24
CodeCommit  (0) 2022.08.24
API authorizers  (0) 2022.08.24
Insight  (0) 2022.08.24
아마존 리눅스 사용법  (0) 2022.08.24
DynamoDB 클라이언트 Tool  (0) 2020.04.28