|
1 | 1 | 'use strict';
|
2 | 2 |
|
3 |
| -var AWS = require('aws-sdk'), |
4 |
| - { |
5 |
| - S3 |
6 |
| - } = require("@aws-sdk/client-s3"); |
| 3 | +var { fromIni } = require('@aws-sdk/credential-providers'); |
| 4 | +var { S3 } = require('@aws-sdk/client-s3'); |
7 | 5 | var CoreObject = require('core-object');
|
8 | 6 | var RSVP = require('rsvp');
|
9 | 7 | var fs = require('fs');
|
@@ -34,20 +32,31 @@ module.exports = CoreObject.extend({
|
34 | 32 | var config = plugin.pluginConfig;
|
35 | 33 | var profile = plugin.readConfig('profile');
|
36 | 34 | var endpoint = plugin.readConfig('endpoint');
|
| 35 | + var credentials; |
37 | 36 |
|
38 | 37 | this._plugin = plugin;
|
39 | 38 |
|
40 |
| - if (profile && !this._plugin.readConfig('s3Client')) { |
41 |
| - this._plugin.log('Using AWS profile from config', { verbose: true }); |
42 |
| - AWS.config.credentials = new AWS.SharedIniFileCredentials({ profile: profile }); |
| 39 | + var providedS3Client = plugin.readConfig("s3Client"); |
| 40 | + |
| 41 | + |
| 42 | + if (profile && !providedS3Client) { |
| 43 | + this._plugin.log("Using AWS profile from config", { verbose: true }); |
| 44 | + credentials = fromIni({ profile: profile }); |
43 | 45 | }
|
44 | 46 |
|
45 | 47 | if (endpoint) {
|
46 |
| - this._plugin.log('Using endpoint from config', { verbose: true }); |
47 |
| - AWS.config.endpoint = new AWS.Endpoint(endpoint); |
| 48 | + this._plugin.log('Using endpoint from config', { verbose: true }); |
48 | 49 | }
|
49 | 50 |
|
50 |
| - this._client = plugin.readConfig('s3Client') || new S3(config); |
| 51 | + this._client = providedS3Client || new S3(config); |
| 52 | + |
| 53 | + if (endpoint) { |
| 54 | + this._client.config.endpoint = endpoint; |
| 55 | + } |
| 56 | + if (credentials) { |
| 57 | + this._client.config.credentials = credentials; |
| 58 | + } |
| 59 | + |
51 | 60 | },
|
52 | 61 |
|
53 | 62 | upload: function(options) {
|
|
0 commit comments