Skip to content

Commit 5401152

Browse files
committed
only store the full bundle as attribute and not a nested dict
1 parent c69282d commit 5401152

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

localstack-core/localstack/services/apigateway/next_gen/execute_api/router.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from localstack.http import Response
1111
from localstack.services.apigateway.models import ApiGatewayStore, apigateway_stores
1212
from localstack.services.edge import ROUTER
13+
from localstack.services.stores import AccountRegionBundle
1314

1415
from .context import RestApiInvocationContext
1516
from .gateway import RestApiGateway
@@ -38,12 +39,14 @@ class ApiGatewayEndpoint:
3839
Gateway to be processed by the handler chain.
3940
"""
4041

41-
def __init__(self, rest_gateway: RestApiGateway = None, store: ApiGatewayStore = None):
42+
def __init__(self, rest_gateway: RestApiGateway = None, store: AccountRegionBundle = None):
4243
self.rest_gateway = rest_gateway or RestApiGateway()
4344
# we only access CrossAccount attributes in the handler, so we use a global store in default account and region
44-
self._global_store = (
45-
store or apigateway_stores[DEFAULT_AWS_ACCOUNT_ID][AWS_REGION_US_EAST_1]
46-
)
45+
self._store = store or apigateway_stores
46+
47+
@property
48+
def _global_store(self) -> ApiGatewayStore:
49+
return self._store[DEFAULT_AWS_ACCOUNT_ID][AWS_REGION_US_EAST_1]
4750

4851
def __call__(self, request: Request, **kwargs: Unpack[RouteHostPathParameters]) -> Response:
4952
"""

localstack-core/localstack/services/apigateway/next_gen/provider.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
TestInvokeMethodRequest,
1919
TestInvokeMethodResponse,
2020
)
21-
from localstack.constants import AWS_REGION_US_EAST_1, DEFAULT_AWS_ACCOUNT_ID
2221
from localstack.services.apigateway.helpers import (
2322
get_apigateway_store,
2423
get_moto_rest_api,
@@ -47,8 +46,7 @@ def __init__(self, router: ApiGatewayRouter = None):
4746
# we initialize the route handler with a global store with default account and region, because it only ever
4847
# access values with CrossAccount attributes
4948
if not router:
50-
store = apigateway_stores[DEFAULT_AWS_ACCOUNT_ID][AWS_REGION_US_EAST_1]
51-
route_handler = ApiGatewayEndpoint(store=store)
49+
route_handler = ApiGatewayEndpoint(store=apigateway_stores)
5250
router = ApiGatewayRouter(ROUTER, handler=route_handler)
5351

5452
super().__init__(router=router)

0 commit comments

Comments
 (0)