@@ -44,17 +44,7 @@ class ServerlessDynamodbLocal {
44
44
}
45
45
} ,
46
46
executeAll : {
47
- lifecycleEvents : [ 'executeAllHandler' ] ,
48
- options : {
49
- region : {
50
- shortcut : 'r' ,
51
- usage : 'Region that dynamodb should be remotely executed'
52
- } ,
53
- stage : {
54
- shortcut : 's' ,
55
- usage : 'Stage that dynamodb should be remotely executed'
56
- }
57
- }
47
+ lifecycleEvents : [ 'executeAllHandler' ]
58
48
} ,
59
49
start : {
60
50
lifecycleEvents : [ 'startHandler' ] ,
@@ -97,7 +87,14 @@ class ServerlessDynamodbLocal {
97
87
lifecycleEvents : [ 'removeHandler' ]
98
88
} ,
99
89
install : {
100
- lifecycleEvents : [ 'installHandler' ]
90
+ lifecycleEvents : [ 'installHandler' ] ,
91
+ options : {
92
+ localPath : {
93
+ shortcut : 'x' ,
94
+ usage : 'Local dynamodb install path'
95
+ }
96
+ }
97
+
101
98
}
102
99
}
103
100
}
@@ -123,17 +120,21 @@ class ServerlessDynamodbLocal {
123
120
} ) ;
124
121
}
125
122
126
- dynamodbOptions ( stage , region ) {
123
+ dynamodbOptions ( region ) {
127
124
let self = this ;
128
125
let credentials , config = self . service . custom . dynamodb || { } ,
129
126
port = config . start && config . start . port || 8000 ,
130
127
dynamoOptions ;
131
-
132
- dynamoOptions = {
128
+ if ( region ) {
129
+ AWS . config . update ( {
130
+ region : region
131
+ } ) ;
132
+ } else {
133
+ dynamoOptions = {
133
134
endpoint : 'http://localhost:' + port ,
134
135
region : 'localhost'
135
136
} ;
136
-
137
+ }
137
138
return {
138
139
raw : new AWS . DynamoDB ( dynamoOptions ) ,
139
140
doc : new AWS . DynamoDB . DocumentClient ( dynamoOptions )
@@ -168,12 +169,11 @@ class ServerlessDynamodbLocal {
168
169
}
169
170
170
171
executeAllHandler ( ) {
171
- let self = this ,
172
- options = this . options ;
172
+ let self = this ;
173
173
return new BbPromise ( function ( resolve , reject ) {
174
- let dynamodb = self . dynamodbOptions ( options . stage , options . region ) ,
174
+ let dynamodb = self . dynamodbOptions ( self . service . provider . region ) ,
175
175
tableOptions = self . tableOptions ( ) ;
176
- dynamodbMigrations . init ( dynamodb , tableOptions . path ) ;
176
+ dynamodbMigrations . init ( dynamodb , tableOptions . path ) ;
177
177
dynamodbMigrations . executeAll ( tableOptions ) . then ( resolve , reject ) ;
178
178
} ) ;
179
179
}
@@ -185,8 +185,10 @@ class ServerlessDynamodbLocal {
185
185
}
186
186
187
187
installHandler ( ) {
188
+ let self = this ,
189
+ options = this . options ;
188
190
return new BbPromise ( function ( resolve ) {
189
- dynamodbLocal . install ( resolve ) ;
191
+ dynamodbLocal . install ( resolve , options . localPath ) ;
190
192
} ) ;
191
193
}
192
194
0 commit comments