Skip to content

Commit c869500

Browse files
author
guntamb
committed
Add SageMaker-UI DER creds endpoint patch
**Description** * Adding `api/creds` endpoint for the Sagemaker Unified Studio user case that to fetch credentials using DomainExecutionRoleCreds profile. **Motivation** * SMUS extensions would require this creds to fetch the data from S3/RedShift/Glue. **Testing Done** * Build CE package and ran locally. Tested building the local image using BYOI **Backwards Compatibility Criteria (if any)** * N/A
1 parent 0c026c5 commit c869500

File tree

7 files changed

+3759
-27
lines changed

7 files changed

+3759
-27
lines changed

patched-vscode/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"update-build-ts-version": "yarn add typescript@next && tsc -p ./build/tsconfig.build.json"
6868
},
6969
"dependencies": {
70+
"@aws-sdk/credential-providers": "^3.388.0",
7071
"@microsoft/1ds-core-js": "^3.2.13",
7172
"@microsoft/1ds-post-js": "^3.2.13",
7273
"@parcel/watcher": "2.1.0",

patched-vscode/remote/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.0.0",
44
"private": true,
55
"dependencies": {
6+
"@aws-sdk/credential-providers": "^3.388.0",
67
"@microsoft/1ds-core-js": "^3.2.13",
78
"@microsoft/1ds-post-js": "^3.2.13",
89
"@parcel/watcher": "2.1.0",

patched-vscode/remote/yarn.lock

Lines changed: 851 additions & 0 deletions
Large diffs are not rendered by default.

patched-vscode/src/vs/server/node/webClientServer.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { IProductConfiguration } from 'vs/base/common/product';
3030
import { isString } from 'vs/base/common/types';
3131
import { CharCode } from 'vs/base/common/charCode';
3232
import { IExtensionManifest } from 'vs/platform/extensions/common/extensions';
33+
import { fromIni } from "@aws-sdk/credential-providers"
3334

3435
const textMimeType: { [ext: string]: string | undefined } = {
3536
'.html': 'text/html',
@@ -103,6 +104,7 @@ export class WebClientServer {
103104
private readonly _webExtensionRoute: string;
104105
private readonly _idleRoute: string;
105106
private readonly _envMetadata: string;
107+
private readonly _derCreds: string;
106108

107109
constructor(
108110
private readonly _connectionToken: ServerConnectionToken,
@@ -120,6 +122,7 @@ export class WebClientServer {
120122
this._webExtensionRoute = `${serverRootPath}/web-extension-resource`;
121123
this._idleRoute = '/api/idle';
122124
this._envMetadata = '/api/env';
125+
this._derCreds = '/api/creds';
123126
}
124127

125128
/**
@@ -151,6 +154,9 @@ export class WebClientServer {
151154
if (pathname === this._envMetadata) {
152155
return this._handleEnvMetadata(req, res);
153156
}
157+
if (pathname === this._derCreds) {
158+
return this._handleDERCreds(req, res);
159+
}
154160

155161
return serveError(req, res, 404, 'Not found.');
156162
} catch (error) {
@@ -507,6 +513,29 @@ export class WebClientServer {
507513
serveError(req, res, 500, error.message);
508514
}
509515
}
516+
517+
/**
518+
* Handles API requests to retrieve the /opt/ml/metadata/resource-metadata.json file.
519+
*/
520+
private async _handleDERCreds(req: http.IncomingMessage, res: http.ServerResponse): Promise<void> {
521+
try {
522+
const derCreds = await fromIni({
523+
profile: "DomainExecutionRoleCreds"
524+
})();
525+
const creds = {
526+
access_key: derCreds.accessKeyId,
527+
secret_key: derCreds.secretAccessKey,
528+
session_token: derCreds.sessionToken
529+
};
530+
res.statusCode = 200;
531+
res.setHeader('Content-Type', 'application/json');
532+
res.setHeader('Cache-Control', 'no-store');
533+
res.setHeader('Expires', '0');
534+
res.end(JSON.stringify(creds));
535+
} catch (error) {
536+
serveError(req, res, 500, error.message);
537+
}
538+
}
510539
}
511540

512541
/**

0 commit comments

Comments
 (0)