Skip to content

Commit 35ee442

Browse files
committed
Added ability to use different AWS profile when not using access keys or session token.
1 parent 6ca52c4 commit 35ee442

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

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) {
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)