Skip to content

Commit 2b92a6f

Browse files
l0minousDiler Zaza
andauthored
feat(stepfunctions): Supporting all regions in Execution ARNs (#7860)
## Problem Currently Execution Details only supports `us-east-1` executions ## Solution Passing region parsed from execution ARN as a meta tag Separating `apiCallMessageHandler` to Execution Details and Workflow Studio message handlers accordingly --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. Co-authored-by: Diler Zaza <[email protected]>
1 parent 70af2bd commit 2b92a6f

File tree

4 files changed

+27
-19
lines changed

4 files changed

+27
-19
lines changed

packages/core/src/stepFunctions/executionDetails/executionDetailProvider.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { ComponentType } from '../messageHandlers/types'
1212
import { isLocalDev, localhost, cdn } from '../constants/webviewResources'
1313
import { handleMessage } from './handleMessage'
1414
import { ExecutionDetailsContext } from '../messageHandlers/types'
15+
import { parseExecutionArnForStateMachine } from '../utils'
1516

1617
/**
1718
* Provider for Execution Details panels.
@@ -89,7 +90,10 @@ export class ExecutionDetailProvider {
8990
// Only include start time tag for express executions (when startTime is provided)
9091
const startTimeTag = startTime ? `<meta name="start-time" content="${startTime}" />` : ''
9192

92-
return `${htmlFileSplit[0]} <head> ${baseTag} ${localeTag} ${darkModeTag} ${componentTypeTag} ${executionArnTag} ${startTimeTag} ${htmlFileSplit[1]}`
93+
const region = parseExecutionArnForStateMachine(executionArn)?.region
94+
const regionTag = `<meta name="region" content="${region}" />`
95+
96+
return `${htmlFileSplit[0]} <head> ${baseTag} ${localeTag} ${darkModeTag} ${componentTypeTag} ${executionArnTag} ${startTimeTag} ${regionTag} ${htmlFileSplit[1]}`
9397
}
9498

9599
/**

packages/core/src/stepFunctions/executionDetails/handleMessage.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ export async function handleMessage(message: Message, context: ExecutionDetailsC
3333
case Command.INIT:
3434
void initMessageHandler(context)
3535
break
36-
case Command.API_CALL:
37-
void apiCallMessageHandler(message as ApiCallRequestMessage, context)
36+
case Command.API_CALL: {
37+
const region = parseExecutionArnForStateMachine(context.executionArn)?.region || 'us-east-1'
38+
void apiCallMessageHandler(message as ApiCallRequestMessage, context, region)
3839
break
40+
}
3941
case Command.START_EXECUTION:
4042
void startExecutionMessageHandler(context)
4143
break

packages/core/src/stepFunctions/messageHandlers/handleMessageHelpers.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
import { Command, Message, MessageType, BaseContext, ApiCallRequestMessage, UnsupportedMessage } from './types'
8-
import { StepFunctionApiHandler } from './stepFunctionApiHandler'
9-
import globals from '../../shared/extensionGlobals'
7+
import { Command, Message, MessageType, BaseContext, UnsupportedMessage, ApiCallRequestMessage } from './types'
108
import { getLogger } from '../../shared/logger/logger'
9+
import { StepFunctionApiHandler } from './stepFunctionApiHandler'
1110

1211
/**
1312
* Handler for managing webview stage load, which updates load notifications.
@@ -20,17 +19,6 @@ export async function loadStageMessageHandler(context: BaseContext) {
2019
}, 100)
2120
}
2221

23-
/**
24-
* Handler for making API calls from the webview and returning the response.
25-
* @param request The request message containing the API to call and the parameters
26-
* @param context The webview context used for returning the API response to the webview
27-
*/
28-
export function apiCallMessageHandler(request: ApiCallRequestMessage, context: BaseContext) {
29-
const logger = getLogger('stepfunctions')
30-
const apiHandler = new StepFunctionApiHandler(globals.awsContext.getCredentialDefaultRegion(), context)
31-
apiHandler.performApiCall(request).catch((error) => logger.error('%s API call failed: %O', request.apiName, error))
32-
}
33-
3422
/**
3523
* Handles unsupported or unrecognized messages by sending a response to the webview. Ensures compatibility with future
3624
* commands and message types, preventing issues if the user has an outdated extension version.
@@ -45,3 +33,15 @@ export async function handleUnsupportedMessage(context: BaseContext, originalMes
4533
originalMessage,
4634
} as UnsupportedMessage)
4735
}
36+
37+
/**
38+
* Handler for making API calls from the webview and returning the response.
39+
* @param request The request message containing the API to call and the parameters
40+
* @param context The webview context used for returning the API response to the webview
41+
* @param region The AWS region to use for the API calls
42+
*/
43+
export function apiCallMessageHandler(request: ApiCallRequestMessage, context: BaseContext, region: string) {
44+
const logger = getLogger('stepfunctions')
45+
const apiHandler = new StepFunctionApiHandler(region, context)
46+
apiHandler.performApiCall(request).catch((error) => logger.error('%s API call failed: %O', request.apiName, error))
47+
}

packages/core/src/stepFunctions/workflowStudio/handleMessage.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ export async function handleMessage(message: Message, context: WebviewContext) {
6565
case Command.OPEN_FEEDBACK:
6666
!isReadonlyMode && void submitFeedback(placeholder, 'Workflow Studio')
6767
break
68-
case Command.API_CALL:
69-
!isReadonlyMode && apiCallMessageHandler(message as ApiCallRequestMessage, context)
68+
case Command.API_CALL: {
69+
const region = globals.awsContext.getCredentialDefaultRegion()
70+
!isReadonlyMode && apiCallMessageHandler(message as ApiCallRequestMessage, context, region)
7071
break
72+
}
7173
default:
7274
void handleUnsupportedMessage(context, message)
7375
break

0 commit comments

Comments
 (0)