Skip to content

Commit 14178e9

Browse files
authored
Merge pull request #71 from seanstar12/master
Allow support for alternate AWS profiles.
2 parents 6ca52c4 + 1d972c5 commit 14178e9

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ This requires both `accessKeyId` and `secretAccessKey` to be defined.
8383

8484
*Default:* `undefined`
8585

86+
### profile
87+
88+
The AWS profile as definied in `~/.aws/credentials`. If this is left undefined,
89+
the normal [AWS SDK credential resolution][5] will take place.
90+
91+
*Default:* `undefined`
92+
8693
### bucket (`required`)
8794

8895
The AWS bucket that the files will be uploaded to.

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = {
1818
defaultConfig: {
1919
filePattern: '**/*.{js,css,png,gif,ico,jpg,map,xml,txt,svg,swf,eot,ttf,woff,woff2,otf}',
2020
prefix: '',
21+
profile: '',
2122
acl: 'public-read',
2223
cacheControl: 'max-age='+TWO_YEAR_CACHE_PERIOD_IN_SEC+', public',
2324
expires: EXPIRE_IN_2030,

lib/s3.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module.exports = CoreObject.extend({
2727
const accessKeyId = this._plugin.readConfig('accessKeyId');
2828
const secretAccessKey = this._plugin.readConfig('secretAccessKey');
2929
const sessionToken = this._plugin.readConfig('sessionToken');
30+
const profile = this._plugin.readConfig('profile');
3031

3132
if (accessKeyId && secretAccessKey) {
3233
this._plugin.log('Using AWS access key id and secret access key from config', { verbose: true });
@@ -39,6 +40,11 @@ module.exports = CoreObject.extend({
3940
s3Options.sessionToken = sessionToken;
4041
}
4142

43+
if (profile && !this._plugin.readConfig('s3Client')) {
44+
this._plugin.log('Using AWS profile from config', { verbose: true });
45+
AWS.config.credentials = new AWS.SharedIniFileCredentials({ profile: profile });
46+
}
47+
4248
this._client = this._plugin.readConfig('s3Client') || new AWS.S3(s3Options);
4349
},
4450

tests/unit/index-nodetest.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ describe('s3 plugin', function() {
3838
sessionToken: 'eeee',
3939
bucket: 'cccc',
4040
region: 'dddd',
41+
profile: 'ffff',
4142
filePattern: '*.{css,js}',
4243
acl: 'authenticated-read',
4344
prefix: '',

0 commit comments

Comments
 (0)