Skip to content

Commit

Permalink
Fixes AWS configuration on restore
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rjz committed Mar 6, 2017
1 parent 77ca065 commit 97b7abe
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/dynamo-restore.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,28 @@ var readline = require('readline');
var DYNAMO_CHUNK_SIZE = 25;

function DynamoRestore(options) {
var params = {};
options = options || {};
options.concurrency = options.concurrency || 200;
options.minConcurrency = 1;
options.maxConcurrency = options.concurrency;
options.readcapacity = options.readcapacity || 5;
options.writecapacity = options.writecapacity || 0;
options.stopOnFailure = options.stopOnFailure || false;
options.awsKey = options.awsKey || process.env.AWS_ACCESS_KEY_ID;
options.awsSecret = options.awsSecret || process.env.AWS_SECRET_ACCESS_KEY;
options.awsRegion = options.awsRegion || process.env.AWS_DEFAULT_REGION || 'ap-southeast-2';

AWS.config.update({
accessKeyId: options.awsKey,
secretAccessKey: options.awsSecret,
region: options.awsRegion
});
if (options.awsRegion) {
params.region = options.awsRegion;
}
else if (!process.AWS_DEFAULT_REGION) {
params.region = 'ap-southeast-2';
}

if (options.awsKey && options.awsSecret) {
params.accessKeyId = options.awsKey;
params.secretAccessKey = options.awsSecret;
}

AWS.config.update(params);

this.options = options;
this.dynamodb = new AWS.DynamoDB();
Expand Down

0 comments on commit 97b7abe

Please sign in to comment.