Skip to content

Commit 5731dc3

Browse files
committed
chore(release): write to new release s3 bucket MONGOSH-2124
This commit adjusts the mongosh release process to dual write to our new release S3 bucket. Instead of using long-lived static credentials, we have moved over to an IAM role and are assuming it via Evergreen's ec2.assume_role and in GitHub Actions via configure-aws-credentials.
1 parent 8a1dd88 commit 5731dc3

File tree

14 files changed

+190
-8
lines changed

14 files changed

+190
-8
lines changed

.evergreen.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4295,10 +4295,17 @@ functions:
42954295
params:
42964296
file: tmp/expansions.yaml
42974297
redacted: true
4298+
- command: ec2.assume_role
4299+
params:
4300+
role_arn: "arn:aws:iam::119629040606:role/s3-access.cdn-origin-compass"
42984301
- command: shell.exec
42994302
params:
43004303
working_dir: src
43014304
shell: bash
4305+
env:
4306+
DOWNLOAD_CENTER_AWS_KEY_NEW: ${AWS_ACCESS_KEY_ID}
4307+
DOWNLOAD_CENTER_AWS_SECRET_NEW: ${AWS_SECRET_ACCESS_KEY}
4308+
DOWNLOAD_CENTER_AWS_SESSION_TOKEN_NEW: ${AWS_SESSION_TOKEN}
43024309
script: |
43034310
set -e
43044311
{
@@ -4362,6 +4369,9 @@ functions:
43624369
params:
43634370
file: tmp/expansions.yaml
43644371
redacted: true
4372+
- command: ec2.assume_role
4373+
params:
4374+
role_arn: "arn:aws:iam::119629040606:role/s3-access.cdn-origin-compass"
43654375
- command: shell.exec
43664376
# silent: true
43674377
params:
@@ -4370,6 +4380,9 @@ functions:
43704380
env:
43714381
devtoolsbot_npm_token: ${devtoolsbot_npm_token}
43724382
node_js_version: ${node_js_version}
4383+
DOWNLOAD_CENTER_AWS_KEY_NEW: ${AWS_ACCESS_KEY_ID}
4384+
DOWNLOAD_CENTER_AWS_SECRET_NEW: ${AWS_SECRET_ACCESS_KEY}
4385+
DOWNLOAD_CENTER_AWS_SESSION_TOKEN_NEW: ${AWS_SESSION_TOKEN}
43734386
script: |
43744387
set -e
43754388
export PUPPETEER_SKIP_DOWNLOAD="true"

.github/workflows/update-cta.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ on:
1919
default: CTA-Production
2020

2121
permissions:
22+
id-token: write
2223
contents: read
2324

2425
jobs:
@@ -34,16 +35,27 @@ jobs:
3435
DOWNLOAD_CENTER_AWS_SECRET: ${{ secrets.DOWNLOAD_CENTER_AWS_SECRET }}
3536
steps:
3637
- uses: actions/checkout@v4
38+
- name: configure aws credentials
39+
uses: aws-actions/[email protected]
40+
with:
41+
role-to-assume: arn:aws:iam::119629040606:role/s3-access.cdn-origin-compass
42+
aws-region: us-east-1
43+
- name: Sts GetCallerIdentity
44+
run: |
45+
aws sts get-caller-identity
3746
- uses: actions/setup-node@v4
3847
with:
3948
node-version: ^20.x
4049
cache: "npm"
41-
4250
- name: Install Dependencies and Compile
4351
run: |
4452
npm ci
4553
npm run compile
4654
4755
- name: Update greeting CTA
56+
env:
57+
DOWNLOAD_CENTER_AWS_KEY_NEW: "${{ env.AWS_ACCESS_KEY_ID }}"
58+
DOWNLOAD_CENTER_AWS_SECRET_NEW: "${{ env.AWS_SECRET_KEY }}"
59+
DOWNLOAD_CENTER_AWS_SESSION_TOKEN_NEW: "${{ env.AWS_SESSION_TOKEN }}"
4860
run: |
4961
npm run update-cta ${{ github.event.inputs.dry-run && '-- --dry-run' || '' }}

config/build.conf.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ module.exports = {
9797
evgAwsSecret: process.env.AWS_SECRET,
9898
downloadCenterAwsKey: process.env.DOWNLOAD_CENTER_AWS_KEY,
9999
downloadCenterAwsSecret: process.env.DOWNLOAD_CENTER_AWS_SECRET,
100+
downloadCenterAwsKeyNew: process.env.DOWNLOAD_CENTER_AWS_KEY_NEW,
101+
downloadCenterAwsSecretNew: process.env.DOWNLOAD_CENTER_AWS_SECRET_NEW,
102+
downloadCenterAwsSessionTokenNew: process.env.DOWNLOAD_CENTER_AWS_SESSION_TOKEN_NEW,
100103
injectedJsonFeedFile: path.join(ROOT, 'config', 'mongosh-versions.json'),
101104
githubToken: process.env.GITHUB_TOKEN,
102105
segmentKey: process.env.SEGMENT_API_KEY,

package-lock.json

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/build/src/config/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export interface Config {
4141
evgAwsSecret?: string;
4242
downloadCenterAwsKey?: string;
4343
downloadCenterAwsSecret?: string;
44+
downloadCenterAwsKeyNew?: string;
45+
downloadCenterAwsSecretNew?: string;
46+
downloadCenterAwsSessionTokenNew?: string;
4447
injectedJsonFeedFile?: string;
4548
githubToken?: string;
4649
segmentKey?: string;

packages/build/src/download-center/artifacts.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { DownloadCenter as DownloadCenterCls } from '@mongodb-js/dl-center';
22
import * as fs from 'fs';
33
import path from 'path';
4-
import { ARTIFACTS_BUCKET, ARTIFACTS_FOLDER } from './constants';
4+
import {
5+
ARTIFACTS_BUCKET,
6+
ARTIFACTS_BUCKET_NEW,
7+
ARTIFACTS_FOLDER,
8+
} from './constants';
59

610
export async function uploadArtifactToDownloadCenter(
711
filePath: string,
@@ -20,3 +24,23 @@ export async function uploadArtifactToDownloadCenter(
2024
fs.createReadStream(filePath)
2125
);
2226
}
27+
28+
export async function uploadArtifactToDownloadCenterNew(
29+
filePath: string,
30+
awsAccessKeyId: string,
31+
awsSecretAccessKey: string,
32+
awsSessionToken: string,
33+
DownloadCenter: typeof DownloadCenterCls = DownloadCenterCls
34+
): Promise<void> {
35+
const dlcenter = new DownloadCenter({
36+
bucket: ARTIFACTS_BUCKET_NEW,
37+
accessKeyId: awsAccessKeyId,
38+
secretAccessKey: awsSecretAccessKey,
39+
sessionToken: awsSessionToken,
40+
});
41+
42+
await dlcenter.uploadAsset(
43+
`${ARTIFACTS_FOLDER}/${path.basename(filePath)}`,
44+
fs.createReadStream(filePath)
45+
);
46+
}

packages/build/src/download-center/config.spec.ts

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const packageInformation = (version: string) =>
4040

4141
const DUMMY_ACCESS_KEY = 'accessKey';
4242
const DUMMY_SECRET_KEY = 'secretKey';
43+
const DUMMY_SESSION_TOKEN = 'sessionToken';
4344
const DUMMY_CTA_CONFIG: CTAConfig = {};
4445

4546
describe('DownloadCenter config', function () {
@@ -273,6 +274,9 @@ describe('DownloadCenter config', function () {
273274
packageInformation('2.0.1'),
274275
DUMMY_ACCESS_KEY,
275276
DUMMY_SECRET_KEY,
277+
DUMMY_ACCESS_KEY,
278+
DUMMY_SECRET_KEY,
279+
DUMMY_SESSION_TOKEN,
276280
'',
277281
false,
278282
DUMMY_CTA_CONFIG,
@@ -290,6 +294,12 @@ describe('DownloadCenter config', function () {
290294
accessKeyId: DUMMY_ACCESS_KEY,
291295
secretAccessKey: DUMMY_SECRET_KEY,
292296
});
297+
expect(dlCenter).to.have.been.calledWith({
298+
bucket: 'cdn-origin-compass',
299+
accessKeyId: DUMMY_ACCESS_KEY,
300+
secretAccessKey: DUMMY_SECRET_KEY,
301+
sessionToken: DUMMY_SESSION_TOKEN,
302+
});
293303

294304
expect(uploadConfig).to.be.calledOnce;
295305

@@ -321,7 +331,7 @@ describe('DownloadCenter config', function () {
321331
tutorial_link: 'test',
322332
});
323333

324-
expect(uploadAsset).to.be.calledOnce;
334+
expect(uploadAsset).to.be.calledTwice;
325335
const [assetKey] = uploadAsset.lastCall.args;
326336
expect(assetKey).to.equal('compass/mongosh.json');
327337
});
@@ -332,6 +342,9 @@ describe('DownloadCenter config', function () {
332342
packageInformation('1.2.2'),
333343
DUMMY_ACCESS_KEY,
334344
DUMMY_SECRET_KEY,
345+
DUMMY_ACCESS_KEY,
346+
DUMMY_SECRET_KEY,
347+
DUMMY_SESSION_TOKEN,
335348
'',
336349
false,
337350
DUMMY_CTA_CONFIG,
@@ -349,6 +362,12 @@ describe('DownloadCenter config', function () {
349362
accessKeyId: DUMMY_ACCESS_KEY,
350363
secretAccessKey: DUMMY_SECRET_KEY,
351364
});
365+
expect(dlCenter).to.have.been.calledWith({
366+
bucket: 'cdn-origin-compass',
367+
accessKeyId: DUMMY_ACCESS_KEY,
368+
secretAccessKey: DUMMY_SECRET_KEY,
369+
sessionToken: DUMMY_SESSION_TOKEN,
370+
});
352371

353372
expect(uploadConfig).to.be.calledOnce;
354373

@@ -377,7 +396,7 @@ describe('DownloadCenter config', function () {
377396
tutorial_link: 'test',
378397
});
379398

380-
expect(uploadAsset).to.be.calledOnce;
399+
expect(uploadAsset).to.be.calledTwice;
381400
const [assetKey, uploadedAsset] = uploadAsset.lastCall.args;
382401
expect(assetKey).to.equal('compass/mongosh.json');
383402
const jsonFeedData = JSON.parse(uploadedAsset);
@@ -431,6 +450,9 @@ describe('DownloadCenter config', function () {
431450
packageInformation('2.0.0'),
432451
DUMMY_ACCESS_KEY,
433452
DUMMY_SECRET_KEY,
453+
DUMMY_ACCESS_KEY,
454+
DUMMY_SECRET_KEY,
455+
DUMMY_SESSION_TOKEN,
434456
path.resolve(
435457
__dirname,
436458
'..',
@@ -455,6 +477,12 @@ describe('DownloadCenter config', function () {
455477
accessKeyId: DUMMY_ACCESS_KEY,
456478
secretAccessKey: DUMMY_SECRET_KEY,
457479
});
480+
expect(dlCenter).to.have.been.calledWith({
481+
bucket: 'cdn-origin-compass',
482+
accessKeyId: DUMMY_ACCESS_KEY,
483+
secretAccessKey: DUMMY_SECRET_KEY,
484+
sessionToken: DUMMY_SESSION_TOKEN,
485+
});
458486

459487
expect(uploadConfig).to.be.calledOnce;
460488

@@ -486,7 +514,7 @@ describe('DownloadCenter config', function () {
486514
tutorial_link: 'test',
487515
});
488516

489-
expect(uploadAsset).to.be.calledOnce;
517+
expect(uploadAsset).to.be.calledTwice;
490518
const [assetKey, uploadedAsset] = uploadAsset.lastCall.args;
491519
expect(assetKey).to.equal('compass/mongosh.json');
492520
const jsonFeedData = JSON.parse(uploadedAsset);
@@ -593,6 +621,9 @@ describe('DownloadCenter config', function () {
593621
config,
594622
DUMMY_ACCESS_KEY,
595623
DUMMY_SECRET_KEY,
624+
DUMMY_ACCESS_KEY,
625+
DUMMY_SECRET_KEY,
626+
DUMMY_SESSION_TOKEN,
596627
dryRun,
597628
dlCenter as any
598629
);
@@ -630,6 +661,9 @@ describe('DownloadCenter config', function () {
630661
config,
631662
DUMMY_ACCESS_KEY,
632663
DUMMY_SECRET_KEY,
664+
DUMMY_ACCESS_KEY,
665+
DUMMY_SECRET_KEY,
666+
DUMMY_SESSION_TOKEN,
633667
false,
634668
dlCenter as any
635669
);
@@ -655,6 +689,9 @@ describe('DownloadCenter config', function () {
655689
ctas,
656690
DUMMY_ACCESS_KEY,
657691
DUMMY_SECRET_KEY,
692+
DUMMY_ACCESS_KEY,
693+
DUMMY_SECRET_KEY,
694+
DUMMY_SESSION_TOKEN,
658695
false,
659696
dlCenter as any
660697
);
@@ -677,6 +714,9 @@ describe('DownloadCenter config', function () {
677714
config,
678715
DUMMY_ACCESS_KEY,
679716
DUMMY_SECRET_KEY,
717+
DUMMY_ACCESS_KEY,
718+
DUMMY_SECRET_KEY,
719+
DUMMY_SESSION_TOKEN,
680720
false,
681721
dlCenter as any
682722
);
@@ -699,6 +739,9 @@ describe('DownloadCenter config', function () {
699739
config,
700740
DUMMY_ACCESS_KEY,
701741
DUMMY_SECRET_KEY,
742+
DUMMY_ACCESS_KEY,
743+
DUMMY_SECRET_KEY,
744+
DUMMY_SESSION_TOKEN,
702745
false,
703746
dlCenter as any
704747
);
@@ -721,6 +764,9 @@ describe('DownloadCenter config', function () {
721764
config,
722765
DUMMY_ACCESS_KEY,
723766
DUMMY_SECRET_KEY,
767+
DUMMY_ACCESS_KEY,
768+
DUMMY_SECRET_KEY,
769+
DUMMY_SESSION_TOKEN,
724770
false,
725771
dlCenter as any
726772
);
@@ -750,6 +796,9 @@ describe('DownloadCenter config', function () {
750796
config,
751797
DUMMY_ACCESS_KEY,
752798
DUMMY_SECRET_KEY,
799+
DUMMY_ACCESS_KEY,
800+
DUMMY_SECRET_KEY,
801+
DUMMY_SESSION_TOKEN,
753802
false,
754803
dlCenter as any
755804
);
@@ -779,6 +828,9 @@ describe('DownloadCenter config', function () {
779828
config,
780829
DUMMY_ACCESS_KEY,
781830
DUMMY_SECRET_KEY,
831+
DUMMY_ACCESS_KEY,
832+
DUMMY_SECRET_KEY,
833+
DUMMY_SESSION_TOKEN,
782834
false,
783835
dlCenter as any
784836
);

0 commit comments

Comments
 (0)