Skip to content

Commit 3935446

Browse files
committed
COMPASS-9160: dual write release artifacts to new bucket
This commit adjusts Compass to write release artifacts to a new S3 bucket. Eventually the old bucket will be removed after we have confirmed that we can serve artifacts from the new bucket. We also use assume role to access this bucket instead of static credentials.
1 parent 38f9671 commit 3935446

File tree

5 files changed

+39
-9
lines changed

5 files changed

+39
-9
lines changed

.evergreen/functions.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,12 +504,18 @@ functions:
504504
content_type: application/x-gzip
505505

506506
publish:
507+
- command: ec2.assume_role
508+
params:
509+
role_arn: "arn:aws:iam::119629040606:role/s3-access.cdn-origin-compass"
507510
- command: shell.exec
508511
params:
509512
working_dir: src
510513
shell: bash
511514
env:
512515
<<: *compass-env
516+
DOWNLOAD_CENTER_NEW_AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
517+
DOWNLOAD_CENTER_NEW_AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
518+
DOWNLOAD_CENTER_NEW_AWS_SESSION_TOKEN: ${AWS_SESSION_TOKEN}
513519
script: |
514520
set -e
515521
# Load environment variables

package-lock.json

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

packages/hadron-build/commands/upload.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const {
1919
getKeyPrefix,
2020
downloadManifest,
2121
uploadAsset,
22+
uploadAssetNew,
2223
uploadManifest,
2324
} = require('../lib/download-center');
2425

@@ -235,6 +236,7 @@ async function uploadAssetsToDownloadCenter(assets, channel, dryRun) {
235236
);
236237
if (!dryRun) {
237238
await uploadAsset(channel, asset);
239+
await uploadAssetNew(channel, asset);
238240
}
239241
cli.info(`${asset.name}: upload to download center completed.`);
240242
});

packages/hadron-build/lib/download-center.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const { DownloadCenter } = require('@mongodb-js/dl-center');
66
const download = require('download');
77

88
const DOWNLOADS_BUCKET = 'downloads.10gen.com';
9+
const DOWNLOADS_BUCKET_NEW = 'cdn-origin-compass';
910
const MANIFEST_BUCKET = 'info-mongodb-com';
1011
const MANIFEST_OBJECT_KEY = 'com-download-center/compass.json';
1112

@@ -32,10 +33,31 @@ const getDownloadCenter = (bucketConfig) => {
3233
});
3334
};
3435

36+
const getDownloadCenterNew = (bucketConfig) => {
37+
requireEnvironmentVariables([
38+
'DOWNLOAD_CENTER_NEW_AWS_ACCESS_KEY_ID',
39+
'DOWNLOAD_CENTER_NEW_AWS_SECRET_ACCESS_KEY',
40+
'DOWNLOAD_CENTER_NEW_AWS_SESSION_TOKEN',
41+
]);
42+
43+
return new DownloadCenter({
44+
...bucketConfig,
45+
accessKeyId: process.env.DOWNLOAD_CENTER_NEW_AWS_ACCESS_KEY_ID,
46+
secretAccessKey: process.env.DOWNLOAD_CENTER_NEW_AWS_SECRET_ACCESS_KEY,
47+
sessionToken: process.env.DOWNLOAD_CENTER_NEW_AWS_SESSION_TOKEN,
48+
});
49+
};
50+
3551
const getKeyPrefix = (channel) => {
3652
return channel && channel !== 'stable' ? `compass/${channel}` : 'compass';
3753
};
3854

55+
const uploadAssetNew = async (channel, asset) => {
56+
const dlCenterNew = getDownloadCenterNew({ bucket: DOWNLOADS_BUCKET_NEW });
57+
const objectKey = `${getKeyPrefix(channel)}/${asset.name}`;
58+
return dlCenterNew.uploadAsset(objectKey, fs.createReadStream(asset.path));
59+
};
60+
3961
const uploadAsset = async (channel, asset) => {
4062
const dlCenter = getDownloadCenter({ bucket: DOWNLOADS_BUCKET });
4163
const objectKey = `${getKeyPrefix(channel)}/${asset.name}`;

packages/hadron-build/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"dependencies": {
2222
"@electron/rebuild": "^3.7.1",
2323
"@mongodb-js/devtools-github-repo": "^1.4.1",
24-
"@mongodb-js/dl-center": "^1.1.7",
24+
"@mongodb-js/dl-center": "^1.2.0",
2525
"@mongodb-js/electron-wix-msi": "^3.0.0",
2626
"@mongodb-js/signing-utils": "^0.3.8",
2727
"@npmcli/arborist": "^6.2.0",

0 commit comments

Comments
 (0)