Skip to content

Comments

Upgrade aws-sdk v2 to @aws-sdk/client-s3 v3 #844

Open
AnkitSegment wants to merge 1 commit intomasterfrom
aws-upgrade
Open

Upgrade aws-sdk v2 to @aws-sdk/client-s3 v3 #844
AnkitSegment wants to merge 1 commit intomasterfrom
aws-upgrade

Conversation

@AnkitSegment
Copy link
Contributor

Summary

  • Migrate scripts/upload-assets.js from the monolithic aws-sdk v2 to the modular @aws-sdk/client-s3 v3 package
  • Reduces devDependency footprint by only installing the S3 client module instead of the entire AWS SDK
  • Pin to @aws-sdk/client-s3@3.722.0, the last version supporting the repo's Node 16 runtime

Changes

scripts/upload-assets.js

  • Replace require('aws-sdk/clients/s3') with const { S3Client, PutObjectCommand } = require('@aws-sdk/client-s3')
  • Use new S3Client({ region, credentials: { ... } }) instead of new S3({ accessKeyId, secretAccessKey, sessionToken, region })
  • Replace s3.putObject(params).promise() with s3.send(new PutObjectCommand(params)) throughout (putObject helper + 2 manifest uploads)

package.json

  • Replace "aws-sdk": "^2.760.0" with "@aws-sdk/client-s3": "3.722.0" in devDependencies

Test Screenshot

The uploadAssets function is used by makefile, when it calls new version of build get uploaded in s3.
Staging commit hash SHA: 532ade6
CDN link: https://cdn.segment.build/next-integrations/manifest-532ade6.json

S3 file update.

Screenshot 2026-02-13 at 2 44 35 PM

Test plan

  • node -c scripts/upload-assets.js — syntax check passes
  • SDK v3 imports and instantiation verified at runtime on Node 16.20.2
  • S3Client, PutObjectCommand, and client.send() all functional
  • yarn test passes (no integration tests affected — this is a build-only script)
  • All PutObjectCommand parameters (Bucket, Key, Body, ContentType, GrantRead, GrantFullControl, ContentEncoding, CacheControl) are identical between v2 and v3 APIs

🤖 Generated with Claude Code

agents:
queue: v1
command:
- apt-get update && apt-get install -y git

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to make these changes as part of the PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AWS-SDK: 3.XX needs node 20 or above, so the buildkite pipeline gets broken.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls help me understand - why is git required here?

}

return s3.putObject(options).promise();
return s3.send(new PutObjectCommand(options));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add await here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passing back a promise as is from an async function is acceptable as long as the parent function is awaited and you don't want to handle any error scenarios for the promise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants