From 2c37a82df2f6fa5b3b5db6a3db81fc9274fe8d80 Mon Sep 17 00:00:00 2001 From: Dean M Date: Thu, 6 Jun 2019 20:55:14 -0700 Subject: [PATCH 1/2] allow aws profile --- index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 675a451..7699a67 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,7 @@ function _list(opts) { let archivePrefix = opts.archivePrefix; let bucket = opts.bucket; let region = opts.region; + let profile = opts.profile; let manifestKey = opts.manifestKey let client = new AWS.S3({ @@ -20,6 +21,12 @@ function _list(opts) { region }); + if (profile) { + AWS.config.credentials = new AWS.SharedIniFileCredentials({ + profile: profile + }); + } + let listObjects = RSVP.denodeify(client.listObjects.bind(client)); let getObject = RSVP.denodeify(client.getObject.bind(client)); @@ -201,6 +208,7 @@ module.exports = { let archivePrefix = this.readConfig('archivePrefix'); let bucket = this.readConfig('bucket'); let region = this.readConfig('region'); + let profile = this.readConfig('profile'); let manifestKey = this.readConfig('manifestKey'); let awsPrefix = this.readConfig('awsPrefix'); @@ -208,7 +216,7 @@ module.exports = { manifestKey = awsPrefix ? `${awsPrefix}/${manifestKey}` : manifestKey; let opts = { - accessKeyId, secretAccessKey, archivePrefix, bucket, region, manifestKey + accessKeyId, secretAccessKey, archivePrefix, bucket, region, profile, manifestKey }; return _list(opts, this) From e4b624d4a106e899598cb1ab156a631753e8b003 Mon Sep 17 00:00:00 2001 From: Dean M Date: Thu, 6 Jun 2019 21:05:53 -0700 Subject: [PATCH 2/2] update readme --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index f21404f..f7e9421 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,11 @@ The AWS secret for the user that has the ability to upload to the `bucket`. This *Default:* `undefined` +### profile +The AWS profile as defined in ~/.aws/credentials. If this is left undefined, the normal AWS SDK credential resolution will take place. + +*Default:* `undefined` + ### bucket (`required`) The AWS bucket that the files will be uploaded to.