1515
1616from aws_durable_execution_sdk_python_testing .exceptions import (
1717 DurableFunctionsTestError ,
18+ ServiceException ,
1819)
1920from aws_durable_execution_sdk_python_testing .model import LambdaContext
2021
@@ -63,6 +64,7 @@ def invoke(
6364 self ,
6465 function_name : str ,
6566 input : DurableExecutionInvocationInput ,
67+ endpoint_url : str | None = None ,
6668 ) -> DurableExecutionInvocationOutput : ... # pragma: no cover
6769
6870 def update_endpoint (
@@ -93,6 +95,7 @@ def invoke(
9395 self ,
9496 function_name : str , # noqa: ARG002
9597 input : DurableExecutionInvocationInput ,
98+ endpoint_url : str | None = None , # noqa: ARG002
9699 ) -> DurableExecutionInvocationOutput :
97100 # TODO: reasses if function_name will be used in future
98101 input_with_client = DurableExecutionInvocationInputWithClient .from_durable_execution_invocation_input (
@@ -140,19 +143,19 @@ def update_endpoint(self, endpoint_url: str, region_name: str) -> None:
140143 self ._current_endpoint = endpoint_url
141144
142145 def _get_client_for_execution (
143- self , durable_execution_arn : str , lambda_endpoint : str | None = None
146+ self ,
147+ durable_execution_arn : str ,
148+ lambda_endpoint : str | None = None ,
149+ region_name : str | None = None ,
144150 ) -> Any :
145151 """Get the appropriate client for this execution."""
146152 # Use provided endpoint or fall back to cached endpoint for this execution
147153 if lambda_endpoint :
148- # Client should already exist from update_endpoint() call
149154 if lambda_endpoint not in self ._endpoint_clients :
150- from aws_durable_execution_sdk_python_testing .exceptions import (
151- ServiceException ,
152- )
153-
154- raise ServiceException (
155- f"Lambda endpoint { lambda_endpoint } not configured. update_endpoint() must be called first."
155+ self ._endpoint_clients [lambda_endpoint ] = boto3 .client (
156+ "lambdainternal" ,
157+ endpoint_url = lambda_endpoint ,
158+ region_name = region_name or "us-east-1" ,
156159 )
157160 return self ._endpoint_clients [lambda_endpoint ]
158161
@@ -188,12 +191,14 @@ def invoke(
188191 self ,
189192 function_name : str ,
190193 input : DurableExecutionInvocationInput ,
194+ endpoint_url : str | None = None ,
191195 ) -> DurableExecutionInvocationOutput :
192196 """Invoke AWS Lambda function and return durable execution result.
193197
194198 Args:
195199 function_name: Name of the Lambda function to invoke
196200 input: Durable execution invocation input
201+ endpoint_url: Lambda endpoint url
197202
198203 Returns:
199204 DurableExecutionInvocationOutput: Result of the function execution
@@ -214,7 +219,9 @@ def invoke(
214219 raise InvalidParameterValueException (msg )
215220
216221 # Get the client for this execution
217- client = self ._get_client_for_execution (input .durable_execution_arn )
222+ client = self ._get_client_for_execution (
223+ input .durable_execution_arn , endpoint_url
224+ )
218225
219226 try :
220227 # Invoke AWS Lambda function using standard invoke method
0 commit comments