You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+37-3Lines changed: 37 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,8 @@ All CLI options are optional:
52
52
--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.
53
53
--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.)
54
54
--optimizeDbBeforeStartup -o Optimizes the underlying database tables before starting up DynamoDB on your computer. You must also specify -dbPath when you use this parameter.
55
-
--migrate -m After starting DynamoDB local, create DynamoDB tables from the Serverless configuration..
55
+
--migrate -m After starting DynamoDB local, create DynamoDB tables from the Serverless configuration.
56
+
--seed -s After starting and migrating dynamodb local, injects seed data into your tables. The --seed option determines which data categories to onload.
56
57
```
57
58
58
59
All the above options can be added to serverless.yml to set default configuration: e.g.
@@ -63,11 +64,12 @@ custom:
63
64
start:
64
65
port: 8000
65
66
inMemory: true
66
-
migration: true
67
+
mirate: true
68
+
seed: true
67
69
```
68
70
69
71
## Migrations: sls dynamodb migrate
70
-
### Configurations
72
+
### Configuration
71
73
In `serverless.yml` add following to execute all the migration upon DynamoDB Local Start
72
74
```yml
73
75
custom:
@@ -94,6 +96,38 @@ resources:
94
96
WriteCapacityUnits: 1
95
97
```
96
98
99
+
## Seeding: sls dynamodb seed
100
+
### Configuration
101
+
102
+
In `serverless.yml` seeding categories are defined under `dynamodb.seed`.
103
+
104
+
If `dynamodb.start.seed` is true, then seeding is performed after table migrations.
105
+
106
+
```yml
107
+
dynamodb:
108
+
start:
109
+
seed: true
110
+
111
+
seed:
112
+
domain:
113
+
sources:
114
+
- table: domain-widgets
115
+
sources: [./domainWidgets.json]
116
+
- table: domain-fidgets
117
+
sources: [./domainFidgets.json]
118
+
test:
119
+
sources:
120
+
- table: users
121
+
sources: [./fake-test-users.json]
122
+
- table: subscriptions
123
+
sources: [./fake-test-subscriptions.json]
124
+
```
125
+
126
+
```bash
127
+
> sls dynamodb seed --seed=domain,test
128
+
> sls dynamodb start --seed=domain,test
129
+
```
130
+
97
131
## Using DynamoDB Local in your code
98
132
You need to add the following parameters to the AWS NODE SDK dynamodb constructor
Copy file name to clipboardExpand all lines: index.js
+11-3Lines changed: 11 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -56,11 +56,11 @@ class ServerlessDynamodbLocal {
56
56
},
57
57
migrate: {
58
58
shortcut: "m",
59
-
usage: "After starting dynamodb local, create DynamoDB tables from the current serverless configuration"
59
+
usage: "After starting dynamodb local, create DynamoDB tables from the current serverless configuration."
60
60
},
61
61
seed: {
62
62
shortcut: "s",
63
-
usage: "After starting and migrating dynamodb local, injects seed data into your tables",
63
+
usage: "After starting and migrating dynamodb local, injects seed data into your tables. The --seed option determines which data categories to onload.",
64
64
}
65
65
}
66
66
},
@@ -170,7 +170,15 @@ class ServerlessDynamodbLocal {
0 commit comments