Skip to content

Commit 70fccdb

Browse files
committed
Allow users to set their AWS profile
Motivation: - Currently the Serverless system does not allow you to access their sdk, hopefully that is coming soon serverless/serverless#1529 This means that if a user has multiple AWS profiles setup they may be using something other than defualt to manage their Serverless framework. Since you cannot access the serverless config yet we should let them specify the profile to use when migrating.
1 parent 78dee88 commit 70fccdb

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

index.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,17 @@ module.exports = function (S) {
5454
description: 'Stage that dynamodb should be remotely executed'
5555
}, {
5656
option: 'table_prefix',
57-
shortcut: 'p',
57+
shortcut: 't',
5858
description: 'Table name prefix'
5959
}, {
6060
option: 'table_suffix',
6161
shortcut: 'x',
6262
description: 'Table name suffix'
63+
},
64+
{
65+
option: 'profile',
66+
shortcut: 'p',
67+
description: 'aws profile'
6368
}
6469
]
6570
});
@@ -78,12 +83,17 @@ module.exports = function (S) {
7883
description: 'Stage that dynamodb should be remotely executed'
7984
}, {
8085
option: 'table_prefix',
81-
shortcut: 'p',
86+
shortcut: 't',
8287
description: 'Table name prefix'
8388
}, {
8489
option: 'table_suffix',
8590
shortcut: 'x',
8691
description: 'Table name suffix'
92+
},
93+
{
94+
option: 'profile',
95+
shortcut: 'p',
96+
description: 'aws profile'
8797
}]
8898
});
8999
S.addAction(this.remove.bind(this), {
@@ -204,6 +214,10 @@ module.exports = function (S) {
204214
execute(evt) {
205215
let self = this,
206216
options = evt.options;
217+
if(options.profile) {
218+
AWS.config.credentials =
219+
new AWS.SharedIniFileCredentials({ profile: options.profile });
220+
}
207221
return new BbPromise(function (resolve, reject) {
208222
let dynamodb = self.dynamodbOptions(options.stage, options.region),
209223
tableOptions = self.tableOptions(options.table_prefix, options.table_suffix);
@@ -215,6 +229,11 @@ module.exports = function (S) {
215229
executeAll(evt) {
216230
let self = this,
217231
options = evt.options;
232+
if(options.profile) {
233+
AWS.config.credentials =
234+
new AWS.SharedIniFileCredentials({ profile: options.profile });
235+
}
236+
218237
return new BbPromise(function (resolve, reject) {
219238
let dynamodb = self.dynamodbOptions(options.stage, options.region),
220239
tableOptions = self.tableOptions(options.table_prefix, options.table_suffix);

0 commit comments

Comments
 (0)