Skip to content

Commit

Permalink
Re-apply upgrade of aws-sdk in preparation for 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemelia committed Mar 28, 2024
1 parent 2772dd5 commit f0ce421
Show file tree
Hide file tree
Showing 3 changed files with 1,200 additions and 182 deletions.
22 changes: 16 additions & 6 deletions lib/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ var _ = require('lodash');
module.exports = CoreObject.extend({
init: function(options) {
this._super(options);
var AWS = require('aws-sdk');

const {
fromIni
} = require('@aws-sdk/credential-providers');

const {
S3
} = require('@aws-sdk/client-s3');

var s3Options = {
region: this.plugin.readConfig('region')
};
Expand Down Expand Up @@ -38,8 +46,10 @@ module.exports = CoreObject.extend({

if (accessKeyId && secretAccessKey) {
this.plugin.log('Using AWS access key id and secret access key from config', { verbose: true });
s3Options.accessKeyId = accessKeyId;
s3Options.secretAccessKey = secretAccessKey;
s3Options.credentials = {
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey,
};
}

if (signatureVersion) {
Expand All @@ -54,15 +64,15 @@ module.exports = CoreObject.extend({

if (profile && !this.plugin.readConfig('s3Client')) {
this.plugin.log('Using AWS profile from config', { verbose: true });
AWS.config.credentials = new AWS.SharedIniFileCredentials({ profile: profile });
s3Options.credentials = fromIni({ profile: profile });
}

if (endpoint) {
this.plugin.log('Using endpoint from config', { verbose: true });
s3Options.endpoint = new AWS.Endpoint(endpoint);
s3Options.endpoint = endpoint;
}

this._client = this.plugin.readConfig('s3Client') || new AWS.S3(s3Options);
this._client = this.plugin.readConfig('s3Client') || new S3(s3Options);
},

upload: function(options) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"test": "node tests/runner.js && ./node_modules/.bin/eslint index.js lib/* tests/**/*-test.js"
},
"dependencies": {
"aws-sdk": "^2.1354.0",
"@aws-sdk/client-s3": "^3.525.0",
"@aws-sdk/credential-providers": "^3.525.0",
"chalk": "^4.1.0",
"core-object": "^3.1.5",
"ember-cli-deploy-plugin": "^0.2.9",
Expand Down
Loading

0 comments on commit f0ce421

Please sign in to comment.