diff --git a/packages/core/src/stepFunctions/executionDetails/executionDetailProvider.ts b/packages/core/src/stepFunctions/executionDetails/executionDetailProvider.ts index 8b1aa19be3c..090b124bd3c 100644 --- a/packages/core/src/stepFunctions/executionDetails/executionDetailProvider.ts +++ b/packages/core/src/stepFunctions/executionDetails/executionDetailProvider.ts @@ -12,6 +12,7 @@ import { ComponentType } from '../messageHandlers/types' import { isLocalDev, localhost, cdn } from '../constants/webviewResources' import { handleMessage } from './handleMessage' import { ExecutionDetailsContext } from '../messageHandlers/types' +import { parseExecutionArnForStateMachine } from '../utils' /** * Provider for Execution Details panels. @@ -89,7 +90,10 @@ export class ExecutionDetailProvider { // Only include start time tag for express executions (when startTime is provided) const startTimeTag = startTime ? `` : '' - return `${htmlFileSplit[0]}
${baseTag} ${localeTag} ${darkModeTag} ${componentTypeTag} ${executionArnTag} ${startTimeTag} ${htmlFileSplit[1]}` + const region = parseExecutionArnForStateMachine(executionArn)?.region + const regionTag = `` + + return `${htmlFileSplit[0]} ${baseTag} ${localeTag} ${darkModeTag} ${componentTypeTag} ${executionArnTag} ${startTimeTag} ${regionTag} ${htmlFileSplit[1]}` } /** diff --git a/packages/core/src/stepFunctions/executionDetails/handleMessage.ts b/packages/core/src/stepFunctions/executionDetails/handleMessage.ts index 7fba7b77633..7d332136b4a 100644 --- a/packages/core/src/stepFunctions/executionDetails/handleMessage.ts +++ b/packages/core/src/stepFunctions/executionDetails/handleMessage.ts @@ -33,9 +33,11 @@ export async function handleMessage(message: Message, context: ExecutionDetailsC case Command.INIT: void initMessageHandler(context) break - case Command.API_CALL: - void apiCallMessageHandler(message as ApiCallRequestMessage, context) + case Command.API_CALL: { + const region = parseExecutionArnForStateMachine(context.executionArn)?.region || 'us-east-1' + void apiCallMessageHandler(message as ApiCallRequestMessage, context, region) break + } case Command.START_EXECUTION: void startExecutionMessageHandler(context) break diff --git a/packages/core/src/stepFunctions/messageHandlers/handleMessageHelpers.ts b/packages/core/src/stepFunctions/messageHandlers/handleMessageHelpers.ts index b0b628fa9c4..406d549e076 100644 --- a/packages/core/src/stepFunctions/messageHandlers/handleMessageHelpers.ts +++ b/packages/core/src/stepFunctions/messageHandlers/handleMessageHelpers.ts @@ -4,10 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { Command, Message, MessageType, BaseContext, ApiCallRequestMessage, UnsupportedMessage } from './types' -import { StepFunctionApiHandler } from './stepFunctionApiHandler' -import globals from '../../shared/extensionGlobals' +import { Command, Message, MessageType, BaseContext, UnsupportedMessage, ApiCallRequestMessage } from './types' import { getLogger } from '../../shared/logger/logger' +import { StepFunctionApiHandler } from './stepFunctionApiHandler' /** * Handler for managing webview stage load, which updates load notifications. @@ -20,17 +19,6 @@ export async function loadStageMessageHandler(context: BaseContext) { }, 100) } -/** - * Handler for making API calls from the webview and returning the response. - * @param request The request message containing the API to call and the parameters - * @param context The webview context used for returning the API response to the webview - */ -export function apiCallMessageHandler(request: ApiCallRequestMessage, context: BaseContext) { - const logger = getLogger('stepfunctions') - const apiHandler = new StepFunctionApiHandler(globals.awsContext.getCredentialDefaultRegion(), context) - apiHandler.performApiCall(request).catch((error) => logger.error('%s API call failed: %O', request.apiName, error)) -} - /** * Handles unsupported or unrecognized messages by sending a response to the webview. Ensures compatibility with future * 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 originalMessage, } as UnsupportedMessage) } + +/** + * Handler for making API calls from the webview and returning the response. + * @param request The request message containing the API to call and the parameters + * @param context The webview context used for returning the API response to the webview + * @param region The AWS region to use for the API calls + */ +export function apiCallMessageHandler(request: ApiCallRequestMessage, context: BaseContext, region: string) { + const logger = getLogger('stepfunctions') + const apiHandler = new StepFunctionApiHandler(region, context) + apiHandler.performApiCall(request).catch((error) => logger.error('%s API call failed: %O', request.apiName, error)) +} diff --git a/packages/core/src/stepFunctions/workflowStudio/handleMessage.ts b/packages/core/src/stepFunctions/workflowStudio/handleMessage.ts index fd656cea3c6..857ff917b39 100644 --- a/packages/core/src/stepFunctions/workflowStudio/handleMessage.ts +++ b/packages/core/src/stepFunctions/workflowStudio/handleMessage.ts @@ -65,9 +65,11 @@ export async function handleMessage(message: Message, context: WebviewContext) { case Command.OPEN_FEEDBACK: !isReadonlyMode && void submitFeedback(placeholder, 'Workflow Studio') break - case Command.API_CALL: - !isReadonlyMode && apiCallMessageHandler(message as ApiCallRequestMessage, context) + case Command.API_CALL: { + const region = globals.awsContext.getCredentialDefaultRegion() + !isReadonlyMode && apiCallMessageHandler(message as ApiCallRequestMessage, context, region) break + } default: void handleUnsupportedMessage(context, message) break