From 26de9bfa6628ef7e100da7bbbd7aff520f32cac9 Mon Sep 17 00:00:00 2001 From: Maha Benzekri Date: Fri, 6 Feb 2026 15:01:30 +0100 Subject: [PATCH 1/4] migrate aws-node-sdk remaining test from sdk v2 parts to v3 Issue: CLDSRV-846 --- bin/ensureServiceUser | 84 ++-- .../aws-node-sdk/test/rateLimit/tooling.js | 73 ++-- .../testServerAccessLogFile.js | 370 +++++++++--------- 3 files changed, 273 insertions(+), 254 deletions(-) diff --git a/bin/ensureServiceUser b/bin/ensureServiceUser index a281ad2dd2..8bcd2ef402 100755 --- a/bin/ensureServiceUser +++ b/bin/ensureServiceUser @@ -8,7 +8,15 @@ const { errors } = require('arsenal'); const { program } = require('commander'); const werelogs = require('werelogs'); const async = require('async'); -const { IAM } = require('aws-sdk'); +const { + IAMClient, + GetUserCommand, + CreateUserCommand, + GetUserPolicyCommand, + PutUserPolicyCommand, + ListAccessKeysCommand, + CreateAccessKeyCommand, +} = require('@aws-sdk/client-iam'); const { version } = require('../package.json'); const systemPrefix = '/scality-internal/'; @@ -33,7 +41,7 @@ function generateUserPolicyDocument() { } function createIAMClient(opts) { - return new IAM({ + return new IAMClient({ endpoint: opts.iamEndpoint, region: 'us-east-1', }); @@ -98,22 +106,18 @@ class UserHandler extends BaseHandler { resourceType = 'user'; async collect() { - return this.iamClient - .getUser({ - UserName: this.serviceName, - }) - .promise() - .then(res => res.User); + const res = await this.iamClient.send(new GetUserCommand({ + UserName: this.serviceName, + })); + return res.User; } async create() { - return this.iamClient - .createUser({ - UserName: this.serviceName, - Path: systemPrefix, - }) - .promise() - .then(res => res.User); + const res = await this.iamClient.send(new CreateUserCommand({ + UserName: this.serviceName, + Path: systemPrefix, + })); + return res.User; } conflicts(u) { @@ -125,26 +129,22 @@ class UserPolicyHandler extends BaseHandler { resourceType = 'userPolicy'; async collect() { - return this.iamClient - .getUserPolicy({ - UserName: this.serviceName, - PolicyName: this.serviceName, - }) - .promise() - .then(() => true); + await this.iamClient.send(new GetUserPolicyCommand({ + UserName: this.serviceName, + PolicyName: this.serviceName, + })); + return true; } async create() { const doc = generateUserPolicyDocument(); - return this.iamClient - .putUserPolicy({ - UserName: this.serviceName, - PolicyName: this.serviceName, - PolicyDocument: JSON.stringify(doc), - }) - .promise() - .then(() => true); + await this.iamClient.send(new PutUserPolicyCommand({ + UserName: this.serviceName, + PolicyName: this.serviceName, + PolicyDocument: JSON.stringify(doc), + })); + return true; } conflicts() { @@ -158,22 +158,18 @@ class AccessKeyHandler extends BaseHandler { async collect() { // if at least one key already exists, the script won't create a new key // and will display the list of existing keys - return this.iamClient - .listAccessKeys({ - UserName: this.serviceName, - MaxItems: 100, - }) - .promise() - .then(res => res.AccessKeyMetadata); + const res = await this.iamClient.send(new ListAccessKeysCommand({ + UserName: this.serviceName, + MaxItems: 100, + })); + return res.AccessKeyMetadata; } async create() { - return this.iamClient - .createAccessKey({ - UserName: this.serviceName, - }) - .promise() - .then(res => res.AccessKey); + const res = await this.iamClient.send(new CreateAccessKeyCommand({ + UserName: this.serviceName, + })); + return res.AccessKey; } conflicts() { @@ -185,7 +181,7 @@ function collectResource(v, done) { v.collect() .then(res => done(null, res)) .catch((err) => { - if (err.code === 'NoSuchEntity') { + if (err.name === 'NoSuchEntity') { return done(); } diff --git a/tests/functional/aws-node-sdk/test/rateLimit/tooling.js b/tests/functional/aws-node-sdk/test/rateLimit/tooling.js index 3734974438..950b466e5e 100644 --- a/tests/functional/aws-node-sdk/test/rateLimit/tooling.js +++ b/tests/functional/aws-node-sdk/test/rateLimit/tooling.js @@ -1,42 +1,65 @@ const nodeFetch = require('node-fetch'); -const AWS = require('aws-sdk'); +const { SignatureV4 } = require('@aws-sdk/signature-v4'); +const { HttpRequest } = require('@aws-sdk/protocol-http'); +const { Sha256 } = require('@aws-crypto/sha256-js'); const xml2js = require('xml2js'); +const { URL } = require('url'); const { getCredentials } = require('../support/credentials'); const { config } = require('../../../../../lib/Config'); const skipIfRateLimitDisabled = config.rateLimiting.enabled ? describe : describe.skip; +function buildHttpRequest(method, host, rawPath, body = '') { + const endpoint = new URL(`http://${host}`); + const target = new URL(rawPath, `http://${host}`); + + const query = {}; + target.searchParams.forEach((value, key) => { + if (Object.prototype.hasOwnProperty.call(query, key)) { + const current = query[key]; + query[key] = Array.isArray(current) ? current.concat(value) : [current, value]; + } else { + query[key] = value ?? ''; + } + }); + + const request = new HttpRequest({ + method: method.toUpperCase(), + protocol: endpoint.protocol, + hostname: endpoint.hostname, + port: endpoint.port ? Number(endpoint.port) : undefined, + path: target.pathname, + query: Object.keys(query).length ? query : undefined, + headers: { + host, + }, + body: body || undefined, + }); + + return { request, target }; +} + async function sendRateLimitRequest(method, host, path, body = '') { - const service = 's3'; - const endpoint = new AWS.Endpoint(host); - - const request = new AWS.HttpRequest(endpoint); - request.method = method.toUpperCase(); - request.path = path; - request.body = body; - request.headers.Host = host; - request.headers['X-Amz-Date'] = new Date().toISOString().replace(/[:\-]|\.\d{3}/g, ''); - const sha256hash = AWS.util.crypto.sha256(request.body || '', 'hex'); - request.headers['X-Amz-Content-SHA256'] = sha256hash; - request.region = 'us-east-1'; - - const signer = new AWS.Signers.V4(request, service); + const { request, target } = buildHttpRequest(method, host, path, body); + const credentials = getCredentials('lisa'); - const awsCredentials = new AWS.Credentials( - credentials.accessKeyId, - credentials.secretAccessKey - ); - signer.addAuthorization(awsCredentials, new Date()); + const signer = new SignatureV4({ + credentials, + region: 'us-east-1', + service: 's3', + sha256: Sha256, + }); + const signedRequest = await signer.sign(request); - const url = `http://${host}${path}`; + const url = target.href; const options = { - method: request.method, - headers: request.headers, + method: signedRequest.method, + headers: signedRequest.headers, }; - if (method !== 'GET' && method !== 'DELETE') { - options.body = request.body; + if (signedRequest.body && method !== 'GET' && method !== 'DELETE') { + options.body = signedRequest.body; } const response = await nodeFetch(url, options); diff --git a/tests/functional/aws-node-sdk/test/serverAccessLogs/testServerAccessLogFile.js b/tests/functional/aws-node-sdk/test/serverAccessLogs/testServerAccessLogFile.js index 604b7b7338..509fda5c0a 100644 --- a/tests/functional/aws-node-sdk/test/serverAccessLogs/testServerAccessLogFile.js +++ b/tests/functional/aws-node-sdk/test/serverAccessLogs/testServerAccessLogFile.js @@ -2,7 +2,7 @@ const assert = require('assert'); const fs = require('fs'); const path = require('path'); const tv4 = require('tv4'); -const { S3 } = require('aws-sdk'); +const { S3 } = require('@aws-sdk/client-s3'); const withV4 = require('../support/withV4'); const { getCredentials } = require('../support/credentials'); @@ -69,7 +69,7 @@ function sleep(ms) { } async function emptyBucket(s3, bucketName, BypassGovernanceRetention = false) { - const data = await s3.listObjectVersions({ Bucket: bucketName }).promise(); + const data = await s3.listObjectVersions({ Bucket: bucketName }); const versions = data.Versions || []; const deleteMarkers = data.DeleteMarkers || []; @@ -79,7 +79,7 @@ async function emptyBucket(s3, bucketName, BypassGovernanceRetention = false) { Key: obj.Key, VersionId: obj.VersionId, ...(BypassGovernanceRetention && { BypassGovernanceRetention }), - }).promise(); + }); } for (const obj of versions.filter(o => o.Key.endsWith('/'))) { await s3.deleteObject({ @@ -87,7 +87,7 @@ async function emptyBucket(s3, bucketName, BypassGovernanceRetention = false) { Key: obj.Key, VersionId: obj.VersionId, ...(BypassGovernanceRetention && { BypassGovernanceRetention }), - }).promise(); + }); } for (const obj of deleteMarkers) { await s3.deleteObject({ @@ -95,27 +95,27 @@ async function emptyBucket(s3, bucketName, BypassGovernanceRetention = false) { Key: obj.Key, VersionId: obj.VersionId, ...(BypassGovernanceRetention && { BypassGovernanceRetention }), - }).promise(); + }); } } async function cleanupBuckets(s3) { let lastAction = 'ListBuckets'; - const bucketsResponse = await s3.listBuckets().promise(); + const bucketsResponse = await s3.listBuckets(); for (const bucket of bucketsResponse.Buckets) { - const listMPUResponse = await s3.listMultipartUploads({ Bucket: bucket.Name }).promise(); + const listMPUResponse = await s3.listMultipartUploads({ Bucket: bucket.Name }); if (listMPUResponse.Uploads && listMPUResponse.Uploads.length > 0) { await Promise.all(listMPUResponse.Uploads.map(upload => s3.abortMultipartUpload({ Bucket: bucket.Name, Key: upload.Key, UploadId: upload.UploadId, - }).promise(), + }), )); } await emptyBucket(s3, bucket.Name, true); - await s3.deleteBucket({ Bucket: bucket.Name }).promise(); + await s3.deleteBucket({ Bucket: bucket.Name }); lastAction = 'DeleteBucket'; } return lastAction; @@ -131,10 +131,10 @@ describe('Server Access Logs - File Output', async () => { withV4(async sigCfg => { const s3 = new S3({ endpoint: 'http://127.0.0.1:8000', - s3ForcePathStyle: true, + forcePathStyle: true, credentials: getCredentials('default', sigCfg), region: 'us-east-1', - maxRetries: 0, + maxAttempts: 1, }); const logFilePath = config.serverAccessLogs.outputFile; const bucketName = 'test-server-access-log-bucket'; @@ -197,8 +197,8 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests deleting a bucket and expects a server access log entry for the bucket deletion. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.deleteBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.deleteBucket({ Bucket: bucketName }); }; return { method, @@ -225,7 +225,7 @@ describe('Server Access Logs - File Output', async () => { // This operation tests deleting a bucket's CORS configuration // and expects a log entry for that operation. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); // CORS must be set before it can be deleted await s3.putBucketCors({ Bucket: bucketName, @@ -236,8 +236,8 @@ describe('Server Access Logs - File Output', async () => { AllowedOrigins: ['*'], }] } - }).promise(); - await s3.deleteBucketCors({ Bucket: bucketName }).promise(); + }); + await s3.deleteBucketCors({ Bucket: bucketName }); }; return { method, @@ -270,7 +270,7 @@ describe('Server Access Logs - File Output', async () => { // This operation tests deleting a bucket's encryption configuration // and expects a log entry for that operation. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); // Bucket encryption must be configured before it can be deleted await s3.putBucketEncryption({ Bucket: bucketName, @@ -283,8 +283,8 @@ describe('Server Access Logs - File Output', async () => { } ] } - }).promise(); - await s3.deleteBucketEncryption({ Bucket: bucketName }).promise(); + }); + await s3.deleteBucketEncryption({ Bucket: bucketName }); }; return { method, @@ -317,7 +317,7 @@ describe('Server Access Logs - File Output', async () => { // This operation tests deleting a bucket's website configuration // and expects a log entry for that operation. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); // Website configuration must be set before it can be deleted await s3.putBucketWebsite({ Bucket: bucketName, @@ -326,8 +326,8 @@ describe('Server Access Logs - File Output', async () => { Suffix: 'index.html', }, }, - }).promise(); - await s3.deleteBucketWebsite({ Bucket: bucketName }).promise(); + }); + await s3.deleteBucketWebsite({ Bucket: bucketName }); }; return { method, @@ -359,11 +359,11 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests the ListBucketV2 API and expects a log entry for that operation. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); // Upload an object to ensure the bucket is not empty - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'Data' }).promise(); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'Data' }); // Issue the ListBucketV2 request - await s3.listObjectsV2({ Bucket: bucketName }).promise(); + await s3.listObjectsV2({ Bucket: bucketName }); }; return { method, @@ -395,11 +395,11 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests the ListObjects (v1) API and expects a log entry for that operation. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); // Upload an object to ensure the bucket is not empty - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'Data' }).promise(); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'Data' }); // Issue the ListObjects request - await s3.listObjects({ Bucket: bucketName }).promise(); + await s3.listObjects({ Bucket: bucketName }); }; return { method, @@ -432,8 +432,8 @@ describe('Server Access Logs - File Output', async () => { // This operation tests getting a bucket's ACL // and expects log entries for bucket creation and getting the ACL. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.getBucketAcl({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.getBucketAcl({ Bucket: bucketName }); }; return { method, @@ -468,9 +468,9 @@ describe('Server Access Logs - File Output', async () => { ] }; const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.putBucketCors({ Bucket: bucketName, CORSConfiguration: corsConfig }).promise(); - await s3.getBucketCors({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.putBucketCors({ Bucket: bucketName, CORSConfiguration: corsConfig }); + await s3.getBucketCors({ Bucket: bucketName }); }; return { method, @@ -504,8 +504,8 @@ describe('Server Access Logs - File Output', async () => { await s3.createBucket({ Bucket: bucketName, ObjectLockEnabledForBucket: true, - }).promise(); - await s3.getObjectLockConfiguration({ Bucket: bucketName }).promise(); + }); + await s3.getObjectLockConfiguration({ Bucket: bucketName }); }; return { method, @@ -530,8 +530,8 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests getting a bucket's versioning configuration. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.getBucketVersioning({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.getBucketVersioning({ Bucket: bucketName }); }; return { method, @@ -556,14 +556,14 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests getting a bucket's website configuration. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketWebsite({ Bucket: bucketName, WebsiteConfiguration: { IndexDocument: { Suffix: 'index.html' }, }, - }).promise(); - await s3.getBucketWebsite({ Bucket: bucketName }).promise(); + }); + await s3.getBucketWebsite({ Bucket: bucketName }); }; return { method, @@ -594,8 +594,8 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests getting a bucket's location. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.getBucketLocation({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.getBucketLocation({ Bucket: bucketName }); }; return { method, @@ -620,7 +620,7 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests getting a bucket's encryption configuration. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketEncryption({ Bucket: bucketName, ServerSideEncryptionConfiguration: { @@ -632,8 +632,8 @@ describe('Server Access Logs - File Output', async () => { } ] } - }).promise(); - await s3.getBucketEncryption({ Bucket: bucketName }).promise(); + }); + await s3.getBucketEncryption({ Bucket: bucketName }); }; return { method, @@ -664,8 +664,8 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests heading a bucket. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.headBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.headBucket({ Bucket: bucketName }); }; return { method, @@ -690,7 +690,7 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests creating a bucket. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); }; return { method, @@ -709,8 +709,8 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests putting a bucket ACL. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.putBucketAcl({ Bucket: bucketName, ACL: 'private' }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.putBucketAcl({ Bucket: bucketName, ACL: 'private' }); }; return { method, @@ -735,7 +735,7 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests putting a bucket CORS configuration. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketCors({ Bucket: bucketName, CORSConfiguration: { @@ -745,7 +745,7 @@ describe('Server Access Logs - File Output', async () => { AllowedOrigins: ['*'], }] } - }).promise(); + }); }; return { method, @@ -770,10 +770,10 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests putting bucket versioning configuration. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketVersioning({ Bucket: bucketName, VersioningConfiguration: { Status: 'Enabled' }, - }).promise(); + }); }; return { method, @@ -798,13 +798,13 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests putting bucket tagging. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketTagging({ Bucket: bucketName, Tagging: { TagSet: [{ Key: 'testKey', Value: 'testValue' }] } - }).promise(); + }); }; return { method, @@ -829,14 +829,14 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests deleting bucket tagging. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketTagging({ Bucket: bucketName, Tagging: { TagSet: [{ Key: 'testKey', Value: 'testValue' }] } - }).promise(); - await s3.deleteBucketTagging({ Bucket: bucketName }).promise(); + }); + await s3.deleteBucketTagging({ Bucket: bucketName }); }; return { method, @@ -868,14 +868,14 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests getting bucket tagging. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketTagging({ Bucket: bucketName, Tagging: { TagSet: [{ Key: 'testKey', Value: 'testValue' }] } - }).promise(); - await s3.getBucketTagging({ Bucket: bucketName }).promise(); + }); + await s3.getBucketTagging({ Bucket: bucketName }); }; return { method, @@ -906,10 +906,10 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests putting bucket replication. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketVersioning({ Bucket: bucketName, VersioningConfiguration: { Status: 'Enabled' }, - }).promise(); + }); await s3.putBucketReplication({ Bucket: bucketName, ReplicationConfiguration: { @@ -924,7 +924,7 @@ describe('Server Access Logs - File Output', async () => { } }] } - }).promise(); + }); }; return { method, @@ -955,10 +955,10 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests getting bucket replication. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketVersioning({ Bucket: bucketName, VersioningConfiguration: { Status: 'Enabled' }, - }).promise(); + }); await s3.putBucketReplication({ Bucket: bucketName, ReplicationConfiguration: { @@ -973,8 +973,8 @@ describe('Server Access Logs - File Output', async () => { } }] } - }).promise(); - await s3.getBucketReplication({ Bucket: bucketName }).promise(); + }); + await s3.getBucketReplication({ Bucket: bucketName }); }; return { method, @@ -1011,10 +1011,10 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests deleting bucket replication. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketVersioning({ Bucket: bucketName, VersioningConfiguration: { Status: 'Enabled' }, - }).promise(); + }); await s3.putBucketReplication({ Bucket: bucketName, ReplicationConfiguration: { @@ -1029,8 +1029,8 @@ describe('Server Access Logs - File Output', async () => { } }] } - }).promise(); - await s3.deleteBucketReplication({ Bucket: bucketName }).promise(); + }); + await s3.deleteBucketReplication({ Bucket: bucketName }); }; return { method, @@ -1068,7 +1068,7 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests putting bucket lifecycle. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketLifecycleConfiguration({ Bucket: bucketName, LifecycleConfiguration: { @@ -1079,7 +1079,7 @@ describe('Server Access Logs - File Output', async () => { Expiration: { Days: 365 } }] } - }).promise(); + }); }; return { method, @@ -1104,7 +1104,7 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests getting bucket lifecycle. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketLifecycleConfiguration({ Bucket: bucketName, LifecycleConfiguration: { @@ -1115,8 +1115,8 @@ describe('Server Access Logs - File Output', async () => { Expiration: { Days: 365 } }] } - }).promise(); - await s3.getBucketLifecycleConfiguration({ Bucket: bucketName }).promise(); + }); + await s3.getBucketLifecycleConfiguration({ Bucket: bucketName }); }; return { method, @@ -1147,7 +1147,7 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests deleting bucket lifecycle. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketLifecycleConfiguration({ Bucket: bucketName, LifecycleConfiguration: { @@ -1158,8 +1158,8 @@ describe('Server Access Logs - File Output', async () => { Expiration: { Days: 365 } }] } - }).promise(); - await s3.deleteBucketLifecycle({ Bucket: bucketName }).promise(); + }); + await s3.deleteBucketLifecycle({ Bucket: bucketName }); }; return { method, @@ -1191,7 +1191,7 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests putting bucket policy. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketPolicy({ Bucket: bucketName, Policy: JSON.stringify({ @@ -1203,7 +1203,7 @@ describe('Server Access Logs - File Output', async () => { Resource: `arn:aws:s3:::${bucketName}/*` }] }) - }).promise(); + }); }; return { method, @@ -1228,7 +1228,7 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests getting bucket policy. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketPolicy({ Bucket: bucketName, Policy: JSON.stringify({ @@ -1240,8 +1240,8 @@ describe('Server Access Logs - File Output', async () => { Resource: `arn:aws:s3:::${bucketName}/*` }] }) - }).promise(); - await s3.getBucketPolicy({ Bucket: bucketName }).promise(); + }); + await s3.getBucketPolicy({ Bucket: bucketName }); }; return { method, @@ -1272,7 +1272,7 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests deleting bucket policy. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketPolicy({ Bucket: bucketName, Policy: JSON.stringify({ @@ -1284,8 +1284,8 @@ describe('Server Access Logs - File Output', async () => { Resource: `arn:aws:s3:::${bucketName}/*` }] }) - }).promise(); - await s3.deleteBucketPolicy({ Bucket: bucketName }).promise(); + }); + await s3.deleteBucketPolicy({ Bucket: bucketName }); }; return { method, @@ -1320,7 +1320,7 @@ describe('Server Access Logs - File Output', async () => { await s3.createBucket({ Bucket: bucketName, ObjectLockEnabledForBucket: true, - }).promise(); + }); await s3.putObjectLockConfiguration({ Bucket: bucketName, ObjectLockConfiguration: { @@ -1332,7 +1332,7 @@ describe('Server Access Logs - File Output', async () => { } } } - }).promise(); + }); }; return { method, @@ -1357,11 +1357,11 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests putting bucket notification configuration. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketNotificationConfiguration({ Bucket: bucketName, NotificationConfiguration: {} - }).promise(); + }); }; return { method, @@ -1386,8 +1386,8 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests getting bucket notification configuration. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.getBucketNotificationConfiguration({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.getBucketNotificationConfiguration({ Bucket: bucketName }); }; return { method, @@ -1412,7 +1412,7 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests putting bucket encryption. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketEncryption({ Bucket: bucketName, ServerSideEncryptionConfiguration: { @@ -1424,7 +1424,7 @@ describe('Server Access Logs - File Output', async () => { } ] } - }).promise(); + }); }; return { method, @@ -1449,11 +1449,11 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests putting bucket logging. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketLogging({ Bucket: bucketName, BucketLoggingStatus: {} - }).promise(); + }); }; return { method, @@ -1478,18 +1478,18 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests getting bucket logging. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); await s3.putBucketLogging({ Bucket: bucketName, BucketLoggingStatus: { LoggingEnabled: { TargetBucket: bucketName, TargetPrefix: 'prefix' }, }, - }).promise(); - await s3.getBucketLogging({ Bucket: bucketName }).promise(); + }); + await s3.getBucketLogging({ Bucket: bucketName }); await s3.putBucketLogging({ Bucket: bucketName, BucketLoggingStatus: {} - }).promise(); + }); }; return { method, @@ -1532,16 +1532,16 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests completing a multipart upload. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); const uploadId = - (await s3.createMultipartUpload({ Bucket: bucketName, Key: objectKey }).promise()).UploadId; + (await s3.createMultipartUpload({ Bucket: bucketName, Key: objectKey })).UploadId; const uploadPartResponse = await s3.uploadPart({ Bucket: bucketName, Key: objectKey, PartNumber: 1, UploadId: uploadId, Body: 'test data' - }).promise(); + }); await s3.completeMultipartUpload({ Bucket: bucketName, Key: objectKey, @@ -1552,7 +1552,7 @@ describe('Server Access Logs - File Output', async () => { PartNumber: 1 }] } - }).promise(); + }); }; return { method, @@ -1592,8 +1592,8 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests initiating a multipart upload. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.createMultipartUpload({ Bucket: bucketName, Key: objectKey }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.createMultipartUpload({ Bucket: bucketName, Key: objectKey }); }; return { method, @@ -1619,9 +1619,9 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests listing multipart uploads. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.createMultipartUpload({ Bucket: bucketName, Key: objectKey }).promise(); - await s3.listMultipartUploads({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.createMultipartUpload({ Bucket: bucketName, Key: objectKey }); + await s3.listMultipartUploads({ Bucket: bucketName }); }; return { method, @@ -1653,17 +1653,17 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests listing parts of a multipart upload. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); const uploadId = - (await s3.createMultipartUpload({ Bucket: bucketName, Key: objectKey }).promise()).UploadId; + (await s3.createMultipartUpload({ Bucket: bucketName, Key: objectKey })).UploadId; await s3.uploadPart({ Bucket: bucketName, Key: objectKey, PartNumber: 1, UploadId: uploadId, Body: 'test data' - }).promise(); - await s3.listParts({ Bucket: bucketName, Key: objectKey, UploadId: uploadId }).promise(); + }); + await s3.listParts({ Bucket: bucketName, Key: objectKey, UploadId: uploadId }); }; return { method, @@ -1703,9 +1703,9 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests deleting multiple objects including a non-existent one. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }).promise(); - await s3.putObject({ Bucket: bucketName, Key: `${objectKey}2`, Body: 'test data 2' }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }); + await s3.putObject({ Bucket: bucketName, Key: `${objectKey}2`, Body: 'test data 2' }); await s3.deleteObjects({ Bucket: bucketName, Delete: { @@ -1715,7 +1715,7 @@ describe('Server Access Logs - File Output', async () => { { Key: `${objectKey}-non-existent` } ] } - }).promise(); + }); }; return { method, @@ -1791,10 +1791,10 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests aborting a multipart upload. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); const uploadId = - (await s3.createMultipartUpload({ Bucket: bucketName, Key: objectKey }).promise()).UploadId; - await s3.abortMultipartUpload({ Bucket: bucketName, Key: objectKey, UploadId: uploadId }).promise(); + (await s3.createMultipartUpload({ Bucket: bucketName, Key: objectKey })).UploadId; + await s3.abortMultipartUpload({ Bucket: bucketName, Key: objectKey, UploadId: uploadId }); }; return { method, @@ -1828,9 +1828,9 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests deleting an object. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }).promise(); - await s3.deleteObject({ Bucket: bucketName, Key: objectKey }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }); + await s3.deleteObject({ Bucket: bucketName, Key: objectKey }); }; return { method, @@ -1864,16 +1864,16 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests deleting object tagging. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }); await s3.putObjectTagging({ Bucket: bucketName, Key: objectKey, Tagging: { TagSet: [{ Key: 'testKey', Value: 'testValue' }] } - }).promise(); - await s3.deleteObjectTagging({ Bucket: bucketName, Key: objectKey }).promise(); + }); + await s3.deleteObjectTagging({ Bucket: bucketName, Key: objectKey }); }; return { method, @@ -1914,9 +1914,9 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests getting an object. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }).promise(); - await s3.getObject({ Bucket: bucketName, Key: objectKey }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }); + await s3.getObject({ Bucket: bucketName, Key: objectKey }); }; return { method, @@ -1949,9 +1949,9 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests getting object ACL. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }).promise(); - await s3.getObjectAcl({ Bucket: bucketName, Key: objectKey }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }); + await s3.getObjectAcl({ Bucket: bucketName, Key: objectKey }); }; return { method, @@ -1987,19 +1987,19 @@ describe('Server Access Logs - File Output', async () => { await s3.createBucket({ Bucket: bucketName, ObjectLockEnabledForBucket: true, - }).promise(); - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }).promise(); + }); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }); await s3.putObjectLegalHold({ Bucket: bucketName, Key: objectKey, LegalHold: { Status: 'ON' } - }).promise(); - await s3.getObjectLegalHold({ Bucket: bucketName, Key: objectKey }).promise(); + }); + await s3.getObjectLegalHold({ Bucket: bucketName, Key: objectKey }); await s3.putObjectLegalHold({ Bucket: bucketName, Key: objectKey, LegalHold: { Status: 'OFF' } - }).promise(); + }); }; return { method, @@ -2049,8 +2049,8 @@ describe('Server Access Logs - File Output', async () => { await s3.createBucket({ Bucket: bucketName, ObjectLockEnabledForBucket: true, - }).promise(); - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }).promise(); + }); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }); const retainUntilDate = new Date(); retainUntilDate.setDate(retainUntilDate.getDate() + 1); await s3.putObjectRetention({ @@ -2060,8 +2060,8 @@ describe('Server Access Logs - File Output', async () => { Mode: 'GOVERNANCE', RetainUntilDate: retainUntilDate } - }).promise(); - await s3.getObjectRetention({ Bucket: bucketName, Key: objectKey }).promise(); + }); + await s3.getObjectRetention({ Bucket: bucketName, Key: objectKey }); }; return { method, @@ -2101,9 +2101,9 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests getting object tagging. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }).promise(); - await s3.getObjectTagging({ Bucket: bucketName, Key: objectKey }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }); + await s3.getObjectTagging({ Bucket: bucketName, Key: objectKey }); }; return { method, @@ -2136,13 +2136,13 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests copying an object. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }); await s3.copyObject({ Bucket: bucketName, CopySource: `${bucketName}/${objectKey}`, Key: `${objectKey}-copy` - }).promise(); + }); }; return { method, @@ -2187,9 +2187,9 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests putting an object ACL. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }).promise(); - await s3.putObjectAcl({ Bucket: bucketName, Key: objectKey, ACL: 'private' }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }); + await s3.putObjectAcl({ Bucket: bucketName, Key: objectKey, ACL: 'private' }); }; return { method, @@ -2225,18 +2225,18 @@ describe('Server Access Logs - File Output', async () => { await s3.createBucket({ Bucket: bucketName, ObjectLockEnabledForBucket: true, - }).promise(); - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }).promise(); + }); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }); await s3.putObjectLegalHold({ Bucket: bucketName, Key: objectKey, LegalHold: { Status: 'ON' } - }).promise(); + }); await s3.putObjectLegalHold({ Bucket: bucketName, Key: objectKey, LegalHold: { Status: 'OFF' } - }).promise(); + }); }; return { method, @@ -2276,15 +2276,15 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests putting object tagging. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }); await s3.putObjectTagging({ Bucket: bucketName, Key: objectKey, Tagging: { TagSet: [{ Key: 'testKey', Value: 'testValue' }] } - }).promise(); + }); }; return { method, @@ -2317,16 +2317,16 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests uploading a part in a multipart upload. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); + await s3.createBucket({ Bucket: bucketName }); const uploadId = - (await s3.createMultipartUpload({ Bucket: bucketName, Key: objectKey }).promise()).UploadId; + (await s3.createMultipartUpload({ Bucket: bucketName, Key: objectKey })).UploadId; await s3.uploadPart({ Bucket: bucketName, Key: objectKey, PartNumber: 1, UploadId: uploadId, Body: 'test data' - }).promise(); + }); }; return { method, @@ -2359,10 +2359,10 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests uploading a part copy in a multipart upload. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data for copy' }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data for copy' }); const uploadId = - (await s3.createMultipartUpload({ Bucket: bucketName, Key: `${objectKey}-mpu` }).promise()) + (await s3.createMultipartUpload({ Bucket: bucketName, Key: `${objectKey}-mpu` })) .UploadId; await s3.uploadPartCopy({ Bucket: bucketName, @@ -2370,7 +2370,7 @@ describe('Server Access Logs - File Output', async () => { PartNumber: 1, UploadId: uploadId, CopySource: `${bucketName}/${objectKey}` - }).promise(); + }); }; return { method, @@ -2425,8 +2425,8 @@ describe('Server Access Logs - File Output', async () => { await s3.createBucket({ Bucket: bucketName, ObjectLockEnabledForBucket: true, - }).promise(); - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }).promise(); + }); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: 'test data' }); const retainUntilDate = new Date(); retainUntilDate.setDate(retainUntilDate.getDate() + 1); await s3.putObjectRetention({ @@ -2436,7 +2436,7 @@ describe('Server Access Logs - File Output', async () => { Mode: 'GOVERNANCE', RetainUntilDate: retainUntilDate } - }).promise(); + }); }; return { method, @@ -2473,20 +2473,20 @@ describe('Server Access Logs - File Output', async () => { // (() => { // // This operation tests the restore object API call. // const method = async () => { - // await s3.createBucket({ Bucket: bucketName }).promise(); + // await s3.createBucket({ Bucket: bucketName }); // await s3.putObject({ // Bucket: bucketName, // Key: objectKey, // Body: 'test data', // StorageClass: 'GLACIER' // Not supported in CloudServer - // }).promise(); + // }); // await s3.restoreObject({ // Bucket: bucketName, // Key: objectKey, // RestoreRequest: { // Days: 1 // } - // }).promise(); + // }); // }; // const expectedOperations = ['REST.PUT.BUCKET','REST.PUT.OBJECT', 'REST.POST.OBJECT']; // return { method, methodName: 'objectRestore', expectedOperations }; @@ -2494,8 +2494,8 @@ describe('Server Access Logs - File Output', async () => { (() => { const testBody = 'Hello, Server Access Logs!'; const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: testBody }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: testBody }); }; return { method, @@ -2521,9 +2521,9 @@ describe('Server Access Logs - File Output', async () => { (() => { const testBody = 'Hello, Server Access Logs!'; const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: testBody }).promise(); - await s3.headObject({ Bucket: bucketName, Key: objectKey }).promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.putObject({ Bucket: bucketName, Key: objectKey, Body: testBody }); + await s3.headObject({ Bucket: bucketName, Key: objectKey }); }; return { method, @@ -2556,8 +2556,8 @@ describe('Server Access Logs - File Output', async () => { (() => { // This operation tests listing all buckets. const method = async () => { - await s3.createBucket({ Bucket: bucketName }).promise(); - await s3.listBuckets().promise(); + await s3.createBucket({ Bucket: bucketName }); + await s3.listBuckets(); }; return { method, @@ -2585,7 +2585,7 @@ describe('Server Access Logs - File Output', async () => { // Test errorCode is set. const method = async () => { try { - await s3.deleteBucket({ Bucket: 'xxx'}).promise(); + await s3.deleteBucket({ Bucket: 'xxx'}); } catch { return; } @@ -2611,7 +2611,7 @@ describe('Server Access Logs - File Output', async () => { // Test errorCode is set for PutObject. const method = async () => { try { - await s3.putObject({ Bucket: 'xxx', Key: 'key', Body: 'test' }).promise(); + await s3.putObject({ Bucket: 'xxx', Key: 'key', Body: 'test' }); } catch { return; } @@ -2638,7 +2638,7 @@ describe('Server Access Logs - File Output', async () => { // Test errorCode is set for GetObject. const method = async () => { try { - await s3.getObject({ Bucket: 'xxx', Key: 'key' }).promise(); + await s3.getObject({ Bucket: 'xxx', Key: 'key' }); } catch { return; } @@ -2666,7 +2666,7 @@ describe('Server Access Logs - File Output', async () => { // // Test errorCode is set. // const method = async () => { // try { - // await s3.deleteBucket({ Bucket: 'UPPERCASE'}).promise(); + // await s3.deleteBucket({ Bucket: 'UPPERCASE'}); // } catch { // return; // } From 6d2af32176b386dad1513b028f27a35c2fc8c623 Mon Sep 17 00:00:00 2001 From: Maha Benzekri Date: Fri, 6 Feb 2026 15:01:53 +0100 Subject: [PATCH 2/4] update documentation with sdk v3 commands Issue: CLDSRV-846 --- docs/CLIENTS.rst | 18 +++++---- docs/GETTING_STARTED.rst | 80 ++++++++++++++++++++-------------------- 2 files changed, 50 insertions(+), 48 deletions(-) diff --git a/docs/CLIENTS.rst b/docs/CLIENTS.rst index fba61178cc..87b9f6f746 100644 --- a/docs/CLIENTS.rst +++ b/docs/CLIENTS.rst @@ -124,14 +124,16 @@ JavaScript .. code:: javascript - const AWS = require('aws-sdk'); - - const s3 = new AWS.S3({ - accessKeyId: 'accessKey1', - secretAccessKey: 'verySecretKey1', - endpoint: 'localhost:8000', - sslEnabled: false, - s3ForcePathStyle: true, + const { S3Client } = require('@aws-sdk/client-s3'); + + const s3 = new S3Client({ + region: 'us-east-1', + endpoint: 'http://localhost:8000', + forcePathStyle: true, + credentials: { + accessKeyId: 'accessKey1', + secretAccessKey: 'verySecretKey1', + }, }); JAVA diff --git a/docs/GETTING_STARTED.rst b/docs/GETTING_STARTED.rst index 1bf2fadd09..eb6c276a28 100644 --- a/docs/GETTING_STARTED.rst +++ b/docs/GETTING_STARTED.rst @@ -247,10 +247,13 @@ if you are using the AWS SDK for JavaScript, instantiate your client like this: .. code:: js - const s3 = new aws.S3({ - endpoint: 'http://127.0.0.1:8000', - s3ForcePathStyle: true, - }); + const { S3Client } = require('@aws-sdk/client-s3'); + + const s3 = new S3Client({ + endpoint: 'http://127.0.0.1:8000', + forcePathStyle: true, + region: 'us-east-1', + }); Setting Your Own Access and Secret Key Pairs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -379,47 +382,44 @@ SSL certificates. Test the Config ^^^^^^^^^^^^^^^ -If aws-sdk is not installed, run ``$> yarn install aws-sdk``. +If the AWS SDK for JavaScript v3 packages are not installed locally, run ``$> yarn add @aws-sdk/client-s3 @aws-sdk/node-http-handler``. Paste the following script into a file named "test.js": .. code:: js - const AWS = require('aws-sdk'); - const fs = require('fs'); - const https = require('https'); - - const httpOptions = { - agent: new https.Agent({ - // path on your host of the self-signed certificate - ca: fs.readFileSync('./ca.crt', 'ascii'), - }), - }; - - const s3 = new AWS.S3({ - httpOptions, - accessKeyId: 'accessKey1', - secretAccessKey: 'verySecretKey1', - // The endpoint must be s3.scality.test, else SSL will not work - endpoint: 'https://s3.scality.test:8000', - sslEnabled: true, - // With this setup, you must use path-style bucket access - s3ForcePathStyle: true, - }); - - const bucket = 'cocoriko'; - - s3.createBucket({ Bucket: bucket }, err => { - if (err) { - return console.log('err createBucket', err); - } - return s3.deleteBucket({ Bucket: bucket }, err => { - if (err) { - return console.log('err deleteBucket', err); - } - return console.log('SSL is cool!'); - }); - }); + const { S3Client, CreateBucketCommand, DeleteBucketCommand } = require('@aws-sdk/client-s3'); + const { NodeHttpHandler } = require('@aws-sdk/node-http-handler'); + const fs = require('fs'); + const https = require('https'); + + const httpsAgent = new https.Agent({ + // path on your host of the self-signed certificate + ca: fs.readFileSync('./ca.crt', 'ascii'), + }); + + const s3 = new S3Client({ + requestHandler: new NodeHttpHandler({ httpsAgent }), + credentials: { + accessKeyId: 'accessKey1', + secretAccessKey: 'verySecretKey1', + }, + endpoint: 'https://s3.scality.test:8000', + forcePathStyle: true, + region: 'us-east-1', + }); + + const bucket = 'cocoriko'; + + (async () => { + try { + await s3.send(new CreateBucketCommand({ Bucket: bucket })); + await s3.send(new DeleteBucketCommand({ Bucket: bucket })); + console.log('SSL is cool!'); + } catch (err) { + console.error('error running sample', err); + } + })(); Now run this script with: From 2abfd032168dc265b546f2ce90899a6bc79acecc Mon Sep 17 00:00:00 2001 From: Maha Benzekri Date: Fri, 6 Feb 2026 15:02:06 +0100 Subject: [PATCH 3/4] remove aws sdk v2 dep Issue: CLDSRV-846 --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 11b16e4f6d..4ad6078b1b 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "@smithy/node-http-handler": "^3.0.0", "arsenal": "git+https://github.com/scality/arsenal#8.3.1", "async": "2.6.4", - "aws-sdk": "^2.1692.0", "bucketclient": "scality/bucketclient#8.2.7", "bufferutil": "^4.0.8", "commander": "^12.1.0", From 2aac5d4067bf21d5395cd30860c22e223aea56f0 Mon Sep 17 00:00:00 2001 From: Maha Benzekri Date: Fri, 6 Feb 2026 15:02:38 +0100 Subject: [PATCH 4/4] bump project version to 9.3.1 Issue: CLDSRV-846 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4ad6078b1b..3ab5d6b6b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@zenko/cloudserver", - "version": "9.3.0", + "version": "9.3.1", "description": "Zenko CloudServer, an open-source Node.js implementation of a server handling the Amazon S3 protocol", "main": "index.js", "engines": {