Skip to content

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

Open
AnkitSegment wants to merge 2 commits into
masterfrom
ankit/aws-sdk-v3-client-s3
Open

AnkitSegment wants to merge 2 commits into
masterfrom
ankit/aws-sdk-v3-client-s3

Conversation

@AnkitSegment

Copy link
Copy Markdown
Contributor

Summary

Why the revert happened

#844 bundled the SDK migration together with a Buildkite CI image bump (Node 12 -> Node 20), since @aws-sdk/client-s3 requires a newer Node runtime than the CI image had. That combined change broke the master merge build on the old segment/analytics-dot-js-integrations Buildkite pipeline, so it was reverted in #847.

Since then, this repo's Buildkite pipeline has migrated to Twilio's org (twilio/cdp-analytics-dot-js-integrations), and .buildkite/pipeline.yml on master already runs on NODE_BROWSER_IMAGE (Node 22). That removes the original blocker, so this PR only touches the SDK usage itself — no CI pipeline/image changes.

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.1098.0" in devDependencies

yarn.lock

  • Regenerated via yarn install; no leftover aws-sdk v2 entries

Test plan

  • node -c scripts/upload-assets.js — syntax check passes
  • S3Client, PutObjectCommand, and client.send() verified to instantiate/work at runtime on Node 22
  • Confirmed no aws-sdk@ v2 entry remains in yarn.lock
  • Buildkite CI on the correct (Twilio) pipeline passes

🤖 Generated with Claude Code

Reapplies the SDK migration from #844 (reverted in #847) without the
CI image bump — master already runs the Twilio Buildkite pipeline on
Node 22, which was the original blocker.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 18, 2026 06:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Migrate the asset upload script from AWS SDK v2 (aws-sdk) to the modular AWS SDK v3 S3 client (@aws-sdk/client-s3) to reduce dependency footprint and reapply the previously reverted SDK migration.

Changes:

  • Update scripts/upload-assets.js to use S3Client + PutObjectCommand and client.send() instead of s3.putObject().promise()
  • Replace aws-sdk with @aws-sdk/client-s3 in package.json devDependencies
  • Regenerate yarn.lock to reflect the new dependency graph with AWS SDK v2 removed

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
scripts/upload-assets.js Switch S3 upload implementation from AWS SDK v2 to v3 command-based client API.
package.json Swap devDependency from aws-sdk to @aws-sdk/client-s3.
yarn.lock Update lockfile to remove aws-sdk v2 and add AWS SDK v3 transitive dependencies.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

staging has run this exact version for a while, so align master to it
instead of jumping to latest.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 18, 2026 07:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.

Comment thread scripts/upload-assets.js
.promise();
await s3.send(new PutObjectCommand({ // upload "latest" manifest file
Bucket: bucket,
Key: key('/manifest-latest.json'),
Comment thread scripts/upload-assets.js

await s3.send(new PutObjectCommand({ // upload hash manifest file
Bucket: bucket,
Key: key(`/manifest-${sha}.json`),
Comment thread package.json
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"aws-sdk": "^2.760.0",
"@aws-sdk/client-s3": "3.988.0",
Comment thread package.json
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"aws-sdk": "^2.760.0",
"@aws-sdk/client-s3": "3.988.0",

@mdkhan-tw mdkhan-tw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you please add why we are making the change?
Could you add some testing artefact here?

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