Skip to content

fix(amazonq): sagemaker vscode remote ssh missing IAM creds #7706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/core/src/shared/lsp/utils/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import * as vscode from 'vscode'
import { ToolkitError } from '../../errors'
import { getErrorMsg, ToolkitError } from '../../errors'
import { Logger } from '../../logger/logger'
import { ChildProcess } from '../../utilities/processUtils'
import { waitUntil } from '../../utilities/timeoutUtils'
Expand Down Expand Up @@ -111,6 +111,10 @@ export function createServerOptions({
// Set USE_IAM_AUTH environment variable for SageMaker environments based on cookie detection
// This tells the language server to use IAM authentication mode instead of SSO mode
const env = { ...process.env }

// eslint-disable-next-line aws-toolkits/no-json-stringify-in-log
getLogger().debug(`[yueny debug] vars in env: ${JSON.stringify(env)}`)

if (isSageMaker()) {
try {
// The command `sagemaker.parseCookies` is registered in VS Code SageMaker environment
Expand All @@ -125,7 +129,13 @@ export function createServerOptions({
}
} catch (err) {
getLogger().warn(`[SageMaker Debug] Failed to parse SageMaker cookies, defaulting to IAM auth: ${err}`)
env.USE_IAM_AUTH = 'true'
const errMsg = getErrorMsg(err as Error)
if (errMsg?.includes("command 'sagemaker.parseCookies' not found")) {
getLogger().warn('[yueny debug] SageMaker cookies not found, set env.USE_IAM_AUTH as false')
env.USE_IAM_AUTH = 'false'
} else {
env.USE_IAM_AUTH = 'true'
}
}

// Log important environment variables for debugging
Expand Down
Loading