@@ -9,7 +9,15 @@ var _ = require('lodash');
9
9
module . exports = CoreObject . extend ( {
10
10
init : function ( options ) {
11
11
this . _super ( options ) ;
12
- var AWS = require ( 'aws-sdk' ) ;
12
+
13
+ const {
14
+ fromIni
15
+ } = require ( '@aws-sdk/credential-providers' ) ;
16
+
17
+ const {
18
+ S3
19
+ } = require ( '@aws-sdk/client-s3' ) ;
20
+
13
21
var s3Options = {
14
22
region : this . plugin . readConfig ( 'region' )
15
23
} ;
@@ -38,8 +46,10 @@ module.exports = CoreObject.extend({
38
46
39
47
if ( accessKeyId && secretAccessKey ) {
40
48
this . plugin . log ( 'Using AWS access key id and secret access key from config' , { verbose : true } ) ;
41
- s3Options . accessKeyId = accessKeyId ;
42
- s3Options . secretAccessKey = secretAccessKey ;
49
+ s3Options . credentials = {
50
+ accessKeyId : accessKeyId ,
51
+ secretAccessKey : secretAccessKey ,
52
+ } ;
43
53
}
44
54
45
55
if ( signatureVersion ) {
@@ -54,15 +64,15 @@ module.exports = CoreObject.extend({
54
64
55
65
if ( profile && ! this . plugin . readConfig ( 's3Client' ) ) {
56
66
this . plugin . log ( 'Using AWS profile from config' , { verbose : true } ) ;
57
- AWS . config . credentials = new AWS . SharedIniFileCredentials ( { profile : profile } ) ;
67
+ s3Options . credentials = fromIni ( { profile : profile } ) ;
58
68
}
59
69
60
70
if ( endpoint ) {
61
71
this . plugin . log ( 'Using endpoint from config' , { verbose : true } ) ;
62
- s3Options . endpoint = new AWS . Endpoint ( endpoint ) ;
72
+ s3Options . endpoint = endpoint ;
63
73
}
64
74
65
- this . _client = this . plugin . readConfig ( 's3Client' ) || new AWS . S3 ( s3Options ) ;
75
+ this . _client = this . plugin . readConfig ( 's3Client' ) || new S3 ( s3Options ) ;
66
76
} ,
67
77
68
78
upload : function ( options ) {
0 commit comments