Skip to content

Commit d41ca13

Browse files
mschaszMichaella Schaszbergerclaude
authored
Upgrade AWS SDK from v2 to v3 in browser release script (#1350)
Co-authored-by: Michaella Schaszberger <michaella.schaszberger@segment.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fa58aa2 commit d41ca13

File tree

4 files changed

+1308
-142
lines changed

4 files changed

+1308
-142
lines changed

.changeset/swift-phones-travel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@segment/analytics-next': minor
3+
---
4+
5+
Upgrade AWS SDK from v2 to v3 in browser release script.

packages/browser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"unfetch": "^4.1.0"
6363
},
6464
"devDependencies": {
65+
"@aws-sdk/client-s3": "^3.540.0",
6566
"@internal/config": "0.0.0",
6667
"@segment/analytics-browser-actions-braze": "^1.3.0",
6768
"@segment/analytics.js-integration": "^3.3.3",
@@ -77,7 +78,6 @@
7778
"@types/mime": "^2.0.3",
7879
"@types/node": "^20",
7980
"@types/serve-handler": "^6.1.0",
80-
"aws-sdk": "^2.814.0",
8181
"circular-dependency-plugin": "^5.2.2",
8282
"compression-webpack-plugin": "^8.0.1",
8383
"ecma-version-validator-webpack-plugin": "^1.2.1",

packages/browser/scripts/release.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-disable no-undef */
33

44
const ex = require('execa')
5-
const S3 = require('aws-sdk/clients/s3')
5+
const { S3Client, PutObjectCommand } = require('@aws-sdk/client-s3')
66
const fs = require('fs-extra')
77
const path = require('path')
88
const mime = require('mime')
@@ -62,11 +62,13 @@ async function getFiles(dir) {
6262
}
6363

6464
async function upload(meta) {
65-
const s3 = new S3({
66-
accessKeyId,
67-
secretAccessKey,
68-
sessionToken,
65+
const s3 = new S3Client({
6966
region: 'us-west-2',
67+
credentials: {
68+
accessKeyId,
69+
secretAccessKey,
70+
sessionToken,
71+
},
7072
})
7173

7274
const files = await getFiles(path.join(process.cwd(), './dist/umd'))
@@ -98,29 +100,29 @@ async function upload(meta) {
98100
options.ContentEncoding = 'gzip'
99101
}
100102

101-
const output = await s3.putObject(options).promise()
102-
await s3.putObject(shadowOptions).promise() // upload build to shadow pipeline bucket as well
103+
const output = await s3.send(new PutObjectCommand(options))
104+
await s3.send(new PutObjectCommand(shadowOptions)) // upload build to shadow pipeline bucket as well
103105

104106
// put latest version with only 5 minutes caching
105-
await s3
106-
.putObject({
107+
await s3.send(
108+
new PutObjectCommand({
107109
...options,
108110
CacheControl: 'public,max-age=300,immutable',
109111
Key: path.join(`analytics-next`, meta.branch, 'latest', f),
110112
})
111-
.promise()
113+
)
112114

113115
// put chunks in a separate path. Regardless of branch, version, etc.
114116
// there are immutable scripts that will be loaded by webpack in runtime
115117
if (filePath.includes('bundle')) {
116118
options.GrantRead = `${cloudfrontCanonicalUserId},${customDomainCanonicalUserId}`
117-
await s3
118-
.putObject({
119+
await s3.send(
120+
new PutObjectCommand({
119121
...options,
120122
Key: path.join(`analytics-next`, 'bundles', f),
121123
CacheControl: 'public,max-age=31536000,immutable',
122124
})
123-
.promise()
125+
)
124126
}
125127

126128
progress++

0 commit comments

Comments
 (0)