77from uuid import uuid4
88
99import boto3 # type: ignore
10+ from botocore .config import Config # type: ignore
11+
1012from aws_durable_execution_sdk_python .execution import (
1113 DurableExecutionInvocationInput ,
1214 DurableExecutionInvocationInputWithClient ,
2931 from aws_durable_execution_sdk_python_testing .execution import Execution
3032
3133
34+ # Max Lambda function timeout is 15 minutes (900s); we give headroom for
35+ # network round-trip and RIE startup.
36+ _LAMBDA_READ_TIMEOUT_SECONDS = 960
37+ _LAMBDA_CLIENT_CONFIG = Config (
38+ read_timeout = _LAMBDA_READ_TIMEOUT_SECONDS ,
39+ retries = {"max_attempts" : 0 },
40+ )
41+
42+
43+ def create_lambda_client (endpoint_url : str | None , region_name : str ) -> Any :
44+ """Create a boto3 Lambda client configured for durable function invocations."""
45+
46+ return boto3 .client (
47+ "lambda" ,
48+ endpoint_url = endpoint_url ,
49+ region_name = region_name ,
50+ config = _LAMBDA_CLIENT_CONFIG ,
51+ )
52+
53+
3254@dataclass (frozen = True )
3355class InvokeResponse :
3456 """Response from invoking a durable function."""
@@ -136,9 +158,7 @@ def __init__(self, lambda_client: Any) -> None:
136158 @staticmethod
137159 def create (endpoint_url : str , region_name : str ) -> LambdaInvoker :
138160 """Create with the boto lambda client."""
139- invoker = LambdaInvoker (
140- boto3 .client ("lambda" , endpoint_url = endpoint_url , region_name = region_name )
141- )
161+ invoker = LambdaInvoker (create_lambda_client (endpoint_url , region_name ))
142162 invoker ._current_endpoint = endpoint_url
143163 invoker ._endpoint_clients [endpoint_url ] = invoker .lambda_client
144164 return invoker
@@ -148,8 +168,8 @@ def update_endpoint(self, endpoint_url: str, region_name: str) -> None:
148168 # Cache client by endpoint to reuse across executions
149169 with self ._lock :
150170 if endpoint_url not in self ._endpoint_clients :
151- self ._endpoint_clients [endpoint_url ] = boto3 . client (
152- "lambda" , endpoint_url = endpoint_url , region_name = region_name
171+ self ._endpoint_clients [endpoint_url ] = create_lambda_client (
172+ endpoint_url , region_name
153173 )
154174 self .lambda_client = self ._endpoint_clients [endpoint_url ]
155175 self ._current_endpoint = endpoint_url
@@ -164,10 +184,8 @@ def _get_client_for_execution(
164184 # Use provided endpoint or fall back to cached endpoint for this execution
165185 if lambda_endpoint :
166186 if lambda_endpoint not in self ._endpoint_clients :
167- self ._endpoint_clients [lambda_endpoint ] = boto3 .client (
168- "lambda" ,
169- endpoint_url = lambda_endpoint ,
170- region_name = region_name or "us-east-1" ,
187+ self ._endpoint_clients [lambda_endpoint ] = create_lambda_client (
188+ lambda_endpoint , region_name or "us-east-1"
171189 )
172190 return self ._endpoint_clients [lambda_endpoint ]
173191
0 commit comments