@@ -36,7 +36,6 @@ import {
3636import { SagemakerUnifiedStudioSpaceNode } from '../../sagemakerunifiedstudio/explorer/nodes/sageMakerUnifiedStudioSpaceNode'
3737import { node } from 'webpack'
3838import { parse } from '@aws-sdk/util-arn-parser'
39- import { storeHyperpodConnection } from './detached-server/hyperpodMappingUtils.js'
4039
4140const localize = nls . loadMessageBundle ( )
4241
@@ -127,41 +126,20 @@ export async function deeplinkConnect(
127126 eksClusterArn: ${ eksClusterArn } `
128127 )
129128
130- getLogger ( ) . info (
131- `sm:deeplinkConnect: Condition check - !domain: ${ ! domain } , eksClusterArn: ${ ! ! eksClusterArn } , workspaceName: ${ ! ! workspaceName } , namespace: ${ ! ! namespace } `
132- )
133-
134129 if ( isRemoteWorkspace ( ) ) {
135130 void vscode . window . showErrorMessage ( ConnectFromRemoteWorkspaceMessage )
136131 return
137132 }
138133
139134 try {
140135 let connectionType = 'sm_dl'
141- let clusterName : string | undefined
142- let region : string | undefined
143136 if ( ! domain && eksClusterArn && workspaceName && namespace ) {
144- const parsed = parse ( eksClusterArn )
145- clusterName = parsed . resource . split ( '/' ) [ 1 ]
146- region = parsed . region
137+ const { accountId, region, clusterName } = parseArn ( eksClusterArn )
147138 connectionType = 'sm_hp'
148- const proposedSession = `${ workspaceName } _${ namespace } _${ clusterName } _${ region } _${ parsed . accountId } `
139+ const proposedSession = `${ workspaceName } _${ namespace } _${ clusterName } _${ region } _${ accountId } `
149140 session = isValidSshHostname ( proposedSession )
150141 ? proposedSession
151- : createValidSshSession ( workspaceName , namespace , clusterName , region , parsed . accountId )
152-
153- await storeHyperpodConnection (
154- workspaceName ,
155- namespace ,
156- eksClusterArn ,
157- clusterName ,
158- clusterName ,
159- undefined ,
160- undefined ,
161- region ,
162- wsUrl ,
163- token
164- )
142+ : createValidSshSession ( workspaceName , namespace , clusterName , region , accountId )
165143 }
166144 const remoteEnv = await prepareDevEnvConnection (
167145 connectionIdentifier ,
@@ -175,10 +153,8 @@ export async function deeplinkConnect(
175153 domain ,
176154 appType ,
177155 workspaceName ,
178- clusterName ,
179- namespace ,
180- region ,
181- eksClusterArn
156+ undefined ,
157+ namespace
182158 )
183159
184160 try {
@@ -220,6 +196,26 @@ export async function deeplinkConnect(
220196 }
221197}
222198
199+ function parseArn ( arn : string ) : { accountId : string ; region : string ; clusterName : string } {
200+ try {
201+ const parsed = parse ( arn )
202+ if ( ! parsed . service ) {
203+ throw new Error ( 'Invalid service' )
204+ }
205+ const clusterName = parsed . resource . split ( '/' ) [ 1 ]
206+ if ( ! clusterName ) {
207+ throw new Error ( 'Invalid cluster name' )
208+ }
209+ return {
210+ accountId : parsed . accountId ,
211+ clusterName,
212+ region : parsed . region ,
213+ }
214+ } catch ( error ) {
215+ throw new Error ( 'Invalid cluster ARN' )
216+ }
217+ }
218+
223219/**
224220 * Validates and sanitizes session names for SSH hostname compliance
225221 */
0 commit comments