From 3f9114a8689fb56cd8630e313cd28a04df7c252e Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Mon, 19 Feb 2024 12:29:25 -0800 Subject: [PATCH] chore: migrate AWS SDK for JavaScript v2 APIs to v3 --- server/modules/search/aws/engine.js | 33 +++++++++++++++++++++++------ server/modules/storage/s3/common.js | 2 +- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/server/modules/search/aws/engine.js b/server/modules/search/aws/engine.js index e703e5c3..f5c110be 100644 --- a/server/modules/search/aws/engine.js +++ b/server/modules/search/aws/engine.js @@ -1,5 +1,8 @@ const _ = require('lodash') -const AWS = require('aws-sdk') + +const { CloudSearch } = require('@aws-sdk/client-cloudsearch'); +const { CloudSearchDomain } = require('@aws-sdk/client-cloudsearch-domain'); + const stream = require('stream') const Promise = require('bluebird') const pipeline = Promise.promisify(stream.pipeline) @@ -18,17 +21,33 @@ module.exports = { */ async init() { WIKI.logger.info(`(SEARCH/AWS) Initializing...`) - this.client = new AWS.CloudSearch({ + this.client = new CloudSearch({ + // The key apiVersion is no longer supported in v3, and can be removed. + // @deprecated The client uses the "latest" apiVersion. apiVersion: '2013-01-01', - accessKeyId: this.config.accessKeyId, - secretAccessKey: this.config.secretAccessKey, + + credentials: { + accessKeyId: this.config.accessKeyId, + secretAccessKey: this.config.secretAccessKey + }, + region: this.config.region }) - this.clientDomain = new AWS.CloudSearchDomain({ + this.clientDomain = new CloudSearchDomain({ + // The key apiVersion is no longer supported in v3, and can be removed. + // @deprecated The client uses the "latest" apiVersion. apiVersion: '2013-01-01', + + // The transformation for endpoint is not implemented. + // Refer to UPGRADING.md on aws-sdk-js-v3 for changes needed. + // Please create/upvote feature request on aws-sdk-js-codemod for endpoint. endpoint: this.config.endpoint, - accessKeyId: this.config.accessKeyId, - secretAccessKey: this.config.secretAccessKey, + + credentials: { + accessKeyId: this.config.accessKeyId, + secretAccessKey: this.config.secretAccessKey + }, + region: this.config.region }) diff --git a/server/modules/storage/s3/common.js b/server/modules/storage/s3/common.js index fa1bc5dc..0b2447a2 100644 --- a/server/modules/storage/s3/common.js +++ b/server/modules/storage/s3/common.js @@ -1,4 +1,4 @@ -const S3 = require('aws-sdk/clients/s3') +const { S3 } = require('@aws-sdk/client-s3'); const stream = require('stream') const Promise = require('bluebird') const pipeline = Promise.promisify(stream.pipeline)