Skip to content

Commit 64d5465

Browse files
Merge branch 'v1' into topics/issue-191
2 parents 92ab986 + b4fff55 commit 64d5465

File tree

3 files changed

+56
-21
lines changed

3 files changed

+56
-21
lines changed

README.md

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ All CLI options are optional:
5151
--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.
5252
--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.)
5353
--optimizeDbBeforeStartup -o Optimizes the underlying database tables before starting up DynamoDB on your computer. You must also specify -dbPath when you use this parameter.
54+
--migration -m After starting dynamodb local, run dynamodb migrations.
55+
--heapInitial The initial heap size
56+
--heapMax The maximum heap size
5457
--migrate -m After starting DynamoDB local, create DynamoDB tables from the Serverless configuration.
5558
--seed -s After starting and migrating dynamodb local, injects seed data into your tables. The --seed option determines which data categories to onload.
5659
--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.
@@ -67,6 +70,8 @@ custom:
6770
start:
6871
port: 8000
6972
inMemory: true
73+
heapInitial: 200m
74+
heapMax: 1g
7075
migrate: true
7176
seed: true
7277
convertEmptyValues: true
@@ -115,23 +120,24 @@ If `dynamodb.start.seed` is true, then seeding is performed after table migratio
115120
If you wish to use raw AWS AttributeValues to specify your seed data instead of Javascript types then simply change the variable of any such json files from `sources:` to `rawsources:`.
116121

117122
```yml
118-
dynamodb:
119-
start:
120-
seed: true
121-
122-
seed:
123-
domain:
124-
sources:
125-
- table: domain-widgets
126-
sources: [./domainWidgets.json]
127-
- table: domain-fidgets
128-
sources: [./domainFidgets.json]
129-
test:
130-
sources:
131-
- table: users
132-
rawsources: [./fake-test-users.json]
133-
- table: subscriptions
134-
sources: [./fake-test-subscriptions.json]
123+
custom:
124+
dynamodb:
125+
start:
126+
seed: true
127+
128+
seed:
129+
domain:
130+
sources:
131+
- table: domain-widgets
132+
sources: [./domainWidgets.json]
133+
- table: domain-fidgets
134+
sources: [./domainFidgets.json]
135+
test:
136+
sources:
137+
- table: users
138+
rawsources: [./fake-test-users.json]
139+
- table: subscriptions
140+
sources: [./fake-test-subscriptions.json]
135141
```
136142

137143
```bash
@@ -160,14 +166,19 @@ var AWS = require('aws-sdk');
160166
```
161167
new AWS.DynamoDB.DocumentClient({
162168
region: 'localhost',
163-
endpoint: 'http://localhost:8000'
169+
endpoint: 'http://localhost:8000',
170+
accessKeyId: 'DEFAULT_ACCESS_KEY', // needed if you don't have aws credentials at all in env
171+
secretAccessKey: 'DEFAULT_SECRET' // needed if you don't have aws credentials at all in env
164172
})
165173
```
166174
e.g. for dynamodb document client sdk
167175
```
168176
new AWS.DynamoDB({
169177
region: 'localhost',
170-
endpoint: 'http://localhost:8000'
178+
endpoint: 'http://localhost:8000',
179+
accessKeyId: 'DEFAULT_ACCESS_KEY', // needed if you don't have aws credentials at all in env
180+
secretAccessKey: 'DEFAULT_SECRET' // needed if you don't have aws credentials at all in env
181+
171182
})
172183
```
173184

index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ class ServerlessDynamodbLocal {
7575
shortcut: "s",
7676
usage: "After starting and migrating dynamodb local, injects seed data into your tables. The --seed option determines which data categories to onload.",
7777
},
78+
migration: {
79+
shortcut: 'm',
80+
usage: 'After starting dynamodb local, run dynamodb migrations'
81+
},
82+
heapInitial: {
83+
usage: 'The initial heap size. Specify megabytes, gigabytes or terabytes using m, b, t. E.g., "2m"'
84+
},
85+
heapMax: {
86+
usage: 'The maximum heap size. Specify megabytes, gigabytes or terabytes using m, b, t. E.g., "2m"'
87+
},
7888
convertEmptyValues: {
7989
shortcut: "e",
8090
usage: "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.",
@@ -332,6 +342,20 @@ class ServerlessDynamodbLocal {
332342
if (migration.Tags) {
333343
delete migration.Tags;
334344
}
345+
if (migration.BillingMode === "PAY_PER_REQUEST") {
346+
delete migration.BillingMode;
347+
348+
const defaultProvisioning = {
349+
ReadCapacityUnits: 5,
350+
WriteCapacityUnits: 5
351+
};
352+
migration.ProvisionedThroughput = defaultProvisioning;
353+
if (migration.GlobalSecondaryIndexes) {
354+
migration.GlobalSecondaryIndexes.forEach((gsi) => {
355+
gsi.ProvisionedThroughput = defaultProvisioning;
356+
});
357+
}
358+
}
335359
dynamodb.raw.createTable(migration, (err) => {
336360
if (err) {
337361
if (err.name === 'ResourceInUseException') {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "serverless-dynamodb-local",
3-
"version": "0.2.35",
3+
"version": "0.2.37",
44
"engines": {
55
"node": ">=4.0"
66
},
@@ -34,7 +34,7 @@
3434
"dependencies": {
3535
"aws-sdk": "^2.7.0",
3636
"bluebird": "^3.4.6",
37-
"dynamodb-localhost": "^0.0.6",
37+
"dynamodb-localhost": "^0.0.7",
3838
"lodash": "^4.17.0"
3939
},
4040
"devDependencies": {

0 commit comments

Comments
 (0)