Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/agent/block_store_services/block_store_s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
'use strict';

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

const config = require('../../../config');
const P = require('../../util/promise');
Expand All @@ -13,10 +12,9 @@ const size_utils = require('../../util/size_utils');
const BlockStoreBase = require('./block_store_base').BlockStoreBase;
const { RpcError } = require('../../rpc');
const { NodeHttpHandler } = require("@smithy/node-http-handler");
const noobaa_s3_client = require('../../sdk/noobaa_s3_client/noobaa_s3_client');


const DEFAULT_REGION = 'us-east-1';

class BlockStoreS3 extends BlockStoreBase {

constructor(options) {
Expand All @@ -40,14 +38,14 @@ class BlockStoreS3 extends BlockStoreBase {
RoleSessionName: 'block_store_operations'
};
} else {
this.s3cloud = new S3({
this.s3cloud = noobaa_s3_client.get_s3_client_v3_params({
endpoint: endpoint,
credentials: {
accessKeyId: this.cloud_info.access_keys.access_key.unwrap(),
secretAccessKey: this.cloud_info.access_keys.secret_key.unwrap(),
},
forcePathStyle: true,
region: DEFAULT_REGION,
region: config.DEFAULT_REGION,
requestHandler: new NodeHttpHandler({
httpsAgent: http_utils.get_default_agent(endpoint)
}),
Expand All @@ -58,13 +56,14 @@ class BlockStoreS3 extends BlockStoreBase {
config.EXPERIMENTAL_DISABLE_S3_COMPATIBLE_DELEGATION.DEFAULT;
this.disable_metadata = config.EXPERIMENTAL_DISABLE_S3_COMPATIBLE_METADATA[this.cloud_info.endpoint_type] ||
config.EXPERIMENTAL_DISABLE_S3_COMPATIBLE_METADATA.DEFAULT;
this.s3cloud = new S3({
this.s3cloud = noobaa_s3_client.get_s3_client_v3_params({
endpoint: endpoint,
forcePathStyle: true,
credentials: {
accessKeyId: this.cloud_info.access_keys.access_key.unwrap(),
secretAccessKey: this.cloud_info.access_keys.secret_key.unwrap(),
},
region: config.DEFAULT_REGION,
applyChecksum: cloud_utils.disable_s3_compatible_bodysigning(endpoint),
requestHandler: new NodeHttpHandler({
httpsAgent: http_utils.get_unsecured_agent(endpoint)
Expand Down
5 changes: 2 additions & 3 deletions src/util/cloud_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const RpcError = require('../rpc/rpc_error');
const http_utils = require('./http_utils');
const string_utils = require('./string_utils');
const AWS = require('aws-sdk');
const { S3 } = require('@aws-sdk/client-s3');
const url = require('url');
const _ = require('lodash');
const SensitiveString = require('./sensitive_string');
Expand All @@ -33,7 +32,7 @@ function find_cloud_connection(account, conn_name) {

async function createSTSS3SDKv3Client(params, additionalParams) {
const creds = await generate_aws_sdkv3_sts_creds(params, additionalParams.RoleSessionName);
return new S3({
return noobaa_s3_client.get_s3_client_v3_params({
credentials: creds,
region: params.region || config.DEFAULT_REGION,
endpoint: additionalParams.endpoint,
Expand Down Expand Up @@ -78,7 +77,7 @@ function get_signed_url(params, expiry = 604800, custom_operation = 'getObject')
sslEnabled: false,
signatureVersion: get_s3_endpoint_signature_ver(params.endpoint),
s3DisableBodySigning: disable_s3_compatible_bodysigning(params.endpoint),
region: 'eu-central-1',
region: params.region || config.DEFAULT_REGION,
httpOptions: {
// Setting the agent is not mandatory in this case as this s3 client
// is only used to acquire a signed Url
Expand Down