Skip to content

Commit 97b7abe

Browse files
author
rjz
committed
Fixes AWS configuration on restore
This change removes environmental inference from the restore script, restoring the usual credential precedence established in `aws-sdk`. The default region (Sydney) is preserved for back-compatibility.
1 parent 77ca065 commit 97b7abe

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

lib/dynamo-restore.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,28 @@ var readline = require('readline');
1414
var DYNAMO_CHUNK_SIZE = 25;
1515

1616
function DynamoRestore(options) {
17+
var params = {};
1718
options = options || {};
1819
options.concurrency = options.concurrency || 200;
1920
options.minConcurrency = 1;
2021
options.maxConcurrency = options.concurrency;
2122
options.readcapacity = options.readcapacity || 5;
2223
options.writecapacity = options.writecapacity || 0;
2324
options.stopOnFailure = options.stopOnFailure || false;
24-
options.awsKey = options.awsKey || process.env.AWS_ACCESS_KEY_ID;
25-
options.awsSecret = options.awsSecret || process.env.AWS_SECRET_ACCESS_KEY;
26-
options.awsRegion = options.awsRegion || process.env.AWS_DEFAULT_REGION || 'ap-southeast-2';
2725

28-
AWS.config.update({
29-
accessKeyId: options.awsKey,
30-
secretAccessKey: options.awsSecret,
31-
region: options.awsRegion
32-
});
26+
if (options.awsRegion) {
27+
params.region = options.awsRegion;
28+
}
29+
else if (!process.AWS_DEFAULT_REGION) {
30+
params.region = 'ap-southeast-2';
31+
}
32+
33+
if (options.awsKey && options.awsSecret) {
34+
params.accessKeyId = options.awsKey;
35+
params.secretAccessKey = options.awsSecret;
36+
}
37+
38+
AWS.config.update(params);
3339

3440
this.options = options;
3541
this.dynamodb = new AWS.DynamoDB();

0 commit comments

Comments
 (0)