Serverless webpack 프로젝트 필요
$ npm install --save serverless-dynamodb-local
added 169 packages, and audited 815 packages in 6s
130 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
// serverless.yml
...
custom:
...
tableName: database
dynamodb:
stages:
- dev
start:
port: 8000
inMemory: true
heapInitial: 200m
heapMax: 1g
migrate: true
seed: true
convertEmptyValues: true
resources:
Resources:
sessionTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.tableName}
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: id
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: type
Projection:
ProjectionType: ALL
KeySchema:
- AttributeName: type
KeyType: HASH
- IndexName: created
Projection:
ProjectionType: ALL
KeySchema:
- AttributeName: type
KeyType: HASH
- AttributeName: created
KeyType: RANGE
AttributeDefinitions:
- AttributeName: id
AttributeType: N
- AttributeName: type
AttributeType: N
- AttributeName: created
AttributeType: N
plugins:
- serverless-dynamodb-local
- serverless-webpack
- serverless-offline
$ sls dynamodb install
Started downloading dynamodb-local from http://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz into /Users/won/Desktop/serverless-template/.dynamodb. Process may take few minutes.
Installation complete!
$ sls offline start
Running "serverless" from node_modules
Dynamodb Local Started, Visit: http://localhost:8000/shell
DynamoDB - created table database
Starting Offline at stage dev (us-east-1)
Offline [http for lambda] listening on http://localhost:3002
Function names exposed for local invocation by aws-sdk:
* hello: serverless-offline-dev-hello
┌─────────────────────────────────────────────────────────────────────────┐
│ │
│ GET | http://localhost:3000/dev/getItem │
│ POST | http://localhost:3000/2015-03-31/functions/hello/invocations │
│ │
└─────────────────────────────────────────────────────────────────────────┘
Server ready: http://localhost:3000 🚀
dynamodb nodejs connect 샘플
https://github.com/wonkyungup/serverless-template/tree/serverless-dynamodb