@@ -12,6 +12,7 @@ var Uploader = require('s3-streaming-upload').Uploader;
1212var ReadableStream = require ( './readable-stream' ) ;
1313
1414function DynamoBackup ( options ) {
15+ var params = { } ;
1516 options = options || { } ;
1617 this . excludedTables = options . excludedTables || [ ] ;
1718 this . includedTables = options . includedTables ;
@@ -21,16 +22,20 @@ function DynamoBackup(options) {
2122 this . stopOnFailure = options . stopOnFailure || false ;
2223 this . base64Binary = options . base64Binary || false ;
2324 this . saveDataPipelineFormat = options . saveDataPipelineFormat || false ;
24- this . awsAccessKey = options . awsAccessKey || process . env . AWS_ACCESS_KEY_ID ;
25- this . awsSecretKey = options . awsSecretKey || process . env . AWS_SECRET_ACCESS_KEY ;
26- this . awsRegion = options . awsRegion || process . env . AWS_DEFAULT_REGION || 'us-east-1' ;
25+ this . awsAccessKey = options . awsAccessKey ;
26+ this . awsSecretKey = options . awsSecretKey ;
27+ this . awsRegion = options . awsRegion ;
2728 this . debug = Boolean ( options . debug ) ;
2829
29- AWS . config . update ( {
30- accessKeyId : this . awsAccessKey ,
31- secretAccessKey : this . secretAccessKey ,
32- region : this . awsRegion
33- } ) ;
30+ if ( this . awsRegion ) {
31+ params . region = this . awsRegion ;
32+ }
33+ if ( this . awsAccessKey && this . awsSecretKey ) {
34+ params . accessKeyId = this . awsAccessKey ;
35+ params . secretAccessKey = this . awsSecretKey ;
36+ }
37+
38+ AWS . config . update ( params ) ;
3439}
3540
3641util . inherits ( DynamoBackup , events . EventEmitter ) ;
@@ -49,15 +54,21 @@ DynamoBackup.prototype.backupTable = function (tableName, backupPath, callback)
4954 backupPath = self . _getBackupPath ( ) ;
5055 }
5156
52- var upload = new Uploader ( {
53- accessKey : self . awsAccessKey ,
54- secretKey : self . awsSecretKey ,
55- region : self . awsRegion ,
56- bucket : self . bucket ,
57- objectName : path . join ( backupPath , tableName + '.json' ) ,
58- stream : stream ,
59- debug : self . debug
60- } ) ;
57+ var params = { } ;
58+ if ( self . awsRegion ) {
59+ params . region = self . awsRegion ;
60+ }
61+ if ( self . awsAccessKey && self . awsSecretKey ) {
62+ params . accessKey = self . awsAccessKey ;
63+ params . secretKey = self . awsSecretKey ;
64+ }
65+
66+ params . bucket = self . bucket ;
67+ params . objectName = path . join ( backupPath , tableName + '.json' ) ;
68+ params . stream = stream ;
69+ params . debug = self . debug ;
70+
71+ var upload = new Uploader ( params ) ;
6172
6273 var startTime = moment . utc ( ) ;
6374 self . emit ( 'start-backup' , tableName , startTime ) ;
0 commit comments