Skip to content

Commit 99bdb0a

Browse files
Merge pull request #34 from AshanFernando/master
Updating readme and version
2 parents 8b73e59 + feaece5 commit 99bdb0a

File tree

2 files changed

+46
-91
lines changed

2 files changed

+46
-91
lines changed

README.md

Lines changed: 45 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,48 @@ serverless-dynamodb-local
66
[![npm version](https://badge.fury.io/js/serverless-dynamodb-local.svg)](https://badge.fury.io/js/serverless-dynamodb-local)
77
[![license](https://img.shields.io/npm/l/serverless-dynamodb-local.svg)](https://www.npmjs.com/package/serverless-dynamodb-local)
88

9-
This Serverless 0.5.x plugin help you to setup dynamodb local instance with much needed features to setup your serverless local development environment.
10-
You can use this with ['serverless-offline'](https://github.com/dherault/serverless-offline) Plugin.
11-
129
## This Plugin Requires
1310
* Serverless V0.5 or newer
1411
* Java Runtime Engine (JRE) version 6.x or newer
1512

1613
## Features
14+
* Install DynamoDB Local
15+
* Start DynamoDB Local with all the parameters supported (e.g port, inMemory, sharedDb)
16+
* Create, Manage and Execute DynamoDB Migration Scripts(Table Creation/ Data Seeds) for DynamoDB Local and Online
1717

18-
* Automatically downloads dynamodb local
19-
* Allow to specify all the supported parameters in dynamodb local (e.g port, inMemory, sharedDb)
20-
* Provide you with a set of serverless commands for dynamodb migrations (e.g seeds, tables)
21-
22-
## Installation
23-
18+
## Install Plugin
2419
`npm install --save serverless-dynamodb-local`
2520

2621
Then in `s-project.json` add following entry to the plugins array: `serverless-dynamodb-local`
22+
e.g `"plugins": ["serverless-dynamodb-local"]`
2723

28-
Like this: `"plugins": ["serverless-dynamodb-local"]`
29-
30-
## Starting Dynamodb Local
31-
32-
In your project root run (Note: Run this command first before any other command, since it will download the dynamodb local):
24+
## Using the Plugin
25+
1) Install DynamoDB Local
3326
`sls dynamodb install`
3427

35-
In your project root run to start dynamodb instance:
28+
2) Start DynamoDB Local (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.
3629
`sls dynamodb start`
3730

38-
DynamoDB will process incoming requests until you stop it. To stop DynamoDB, type Ctrl+C in the command prompt window
31+
3) Create/Execute DynamoDB (Migrations)
32+
* Create a new migration file (Default directory path /dynamodb). Make sure DynamoDB Local is started in another shell.
33+
`sls dynamodb create -n <filename>`
34+
35+
* Execute a single migration. Make sure DynamoDB Local is started in another shell.
36+
`sls dynamodb execute -n <filename>`
37+
38+
* Execute all migrations for DynamoDB Local.
39+
`sls dynamodb executeAll`
3940

41+
* Execute migration(s) in remote DynamoDB use additional parameters(region and stage) after execute/executeAll. e.g.
42+
`sls dynamodb executeAll -r us-west-1 -s dev`
43+
44+
Note: Read the detailed section for more information on advanced options and configurations
45+
46+
## Install: `sls dynamodb install`
47+
To remove the installed dynamodb local, run:
48+
`sls dynamodb remove`
49+
50+
## Start: `sls dynamodb start`
4051
All CLI options are optional:
4152

4253
```
@@ -64,39 +75,32 @@ All the above options can be added to s-project.json to set default configuratio
6475
}
6576
```
6677

67-
To remove the installed dynamodb local, run:
68-
`sls dynamodb remove`
69-
70-
## Manage Migrations
71-
72-
Start dynamodb local instance in another window before running the following commands. To store your dynamodb migration templates do the following configuration (If not specified default directory <project-root>/dynamodb is used)
73-
78+
## Create/Execute DynamoDB (Migrations)
79+
### Configurations
80+
In `s-project.json` add following to customize DynamoDB Migrations file directory and table prefixes/suffixes
7481
```json
7582
"custom": {
7683
"dynamodb": {
7784
"migration": {
78-
"dir": "dynamodbTables",
85+
"dir": "dynamodbMigrations",
7986
"table_prefix": "",
8087
"table_suffix": ""
8188
}
8289
}
8390
}
8491
```
8592

86-
To create new migration template with the given name, run:
87-
`sls dynamodb create -n <migration-name>`
88-
89-
To execute a migration template with the given name, run:
90-
`sls dynamodb execute -n <migration-file-name>`
91-
92-
To execute all migration templates, run:
93-
`sls dynamodb executeAll`
94-
95-
Note: Optionally to execute/executeAll migrations on remote dynamodb, use -r <region> and -s <stage> parameters
96-
'sls dynamodb executeAll -r us-west-1 -s dev'
97-
98-
## Migration Template
99-
93+
In `s-project.json` add following to execute all the migration upon DynamoDB Local Start
94+
```json
95+
"custom": {
96+
"dynamodb": {
97+
"start": {
98+
"migration": true
99+
}
100+
}
101+
}
102+
```
103+
### Migration Template
100104
```json
101105
{
102106
"Table": {
@@ -158,31 +162,10 @@ Note: Optionally to execute/executeAll migrations on remote dynamodb, use -r <re
158162
}]
159163
}
160164
```
161-
Before modifying the migration template, refer the Dynamodb Client SDK and Dynamodb Document Client SDK links.
162-
163-
This will create a template json inside configured directory. Open the file and edit the table schema and data.
164-
165-
References
166-
* Defining table schema (Dynamodb Client SDK): http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#createTable-property
167-
* Defining seeds (Dynamodb Document Client SDK): http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#put-property
168-
169-
If you need to prefix_<your-table-name>_suffix, you can configure the values accordingly. This is usefull when you have multiple stages which needs multiple database tables
170-
171-
Optionally if you want to execute all migrations on dynamodb starts, use the argument -m or add the "migration": true inside s-project.json as shown below
172-
173-
```json
174-
"custom": {
175-
"dynamodb": {
176-
"start": {
177-
"migration": true
178-
}
179-
}
180-
}
181-
```
165+
Before modifying the migration template, refer the (Dynamodb Client SDK): http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#createTable-property and (Dynamodb Document Client SDK): http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#put-property links.
182166

183-
## Using in code
184-
185-
You need to add the following parameters to the AWS SDK dynamodb constructor
167+
## Using DynamoDB Local in your code
168+
You need to add the following parameters to the AWS NODE SDK dynamodb constructor
186169

187170
e.g. for dynamodb document client sdk
188171
```
@@ -200,40 +183,12 @@ new AWS.DynamoDB({
200183
201184
```
202185
Open a browser and go to the url http://localhost:8000/shell to access the web shell for dynamodb local
203-
204186
Note: Default port: 8000 and if you change the port, change it accordingly in usage
205187

206188
## Links
207-
208189
* [Dynamodb local documentation](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html)
209190
* [Contact Us](mailto:[email protected])
210191
* [NPM Registry](https://www.npmjs.com/package/serverless-dynamodb-local)
211192

212-
## Contributing
213-
214-
We love our contributors! If you'd like to contribute to the project, feel free to submit a PR. But please keep in mind the following guidelines:
215-
216-
* Propose your changes before you start working on a PR. You can reach us by submitting a Github issue. This is just to make sure that no one else is working on the same change, and to figure out the best way to solve the issue.
217-
* If you're out of ideas, but still want to contribute, help us in solving Github issues already verified.
218-
* Contributions are not just PRs! We'd be grateful for having you, and if you could provide some support for new comers, that be great! You can also do that by answering this plugin related questions on Stackoverflow.
219-
You can also contribute by writing. Feel free to let us know if you want to publish a useful guides, improve the documentation (attributed to you, thank you!) that you feel will help the community.
220-
221-
## Development Setup
222-
223-
* Make a Serverless Project dedicated for plugin development, or use an existing Serverless Project
224-
* Make a "plugins" folder in the root of your Project and copy this codebase into it. Title it your custom plugin name with the suffix "-dev", like "serverless-dynamodb-local-dev"
225-
* Go to root of your Project and edit the s-project.json and add
226-
```
227-
"plugins": [
228-
"serverless-dynamodb-local-dev"
229-
]
230-
```
231-
* Open a commandline from your root Project folder and Start a new dynamodb instance by running
232-
```
233-
sls dynamodb start
234-
```
235-
* Go to dynamodb local [shell](http://localhost:8000/shell) in your browser and you should be able to see use the web shell
236-
237193
## License
238-
239194
[MIT](LICENSE)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "serverless-dynamodb-local",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"engines": {
55
"node": ">=4.0"
66
},

0 commit comments

Comments
 (0)