|
12 | 12 | import boto3 |
13 | 13 | import requests |
14 | 14 | from botocore.awsrequest import AWSPreparedRequest |
15 | | -from botocore.model import OperationModel |
| 15 | +from botocore.model import OperationModel, ServiceModel |
| 16 | +from botocore.session import get_session as get_botocore_session |
| 17 | +from localstack.aws.protocol.parser import create_parser |
16 | 18 | from localstack import config as localstack_config |
17 | 19 | from localstack.config import external_service_url |
18 | 20 | from localstack.constants import ( |
|
43 | 45 | from aws_proxy import config as repl_config |
44 | 46 | from aws_proxy.client.utils import truncate_content |
45 | 47 | from aws_proxy.config import HANDLER_PATH_PROXIES |
46 | | -from aws_proxy.shared.constants import HEADER_HOST_ORIGINAL |
| 48 | +from aws_proxy.shared.constants import HEADER_HOST_ORIGINAL, SERVICE_NAME_MAPPING |
47 | 49 | from aws_proxy.shared.models import AddProxyRequest, ProxyConfig |
48 | 50 |
|
49 | 51 | LOG = logging.getLogger(__name__) |
50 | 52 | LOG.setLevel(logging.INFO) |
51 | 53 | if localstack_config.DEBUG: |
52 | 54 | LOG.setLevel(logging.DEBUG) |
53 | 55 |
|
54 | | -# Mapping from AWS service signing names to boto3 client names |
55 | | -SERVICE_NAME_MAPPING = { |
56 | | - "monitoring": "cloudwatch", |
57 | | -} |
58 | 56 |
|
59 | 57 | # TODO make configurable |
60 | 58 | CLI_PIP_PACKAGE = "localstack-extension-aws-proxy" |
@@ -197,8 +195,6 @@ def deregister_from_instance(self): |
197 | 195 | def _parse_aws_request( |
198 | 196 | self, request: Request, service_name: str, region_name: str, client |
199 | 197 | ) -> Tuple[OperationModel, AWSPreparedRequest, Dict]: |
200 | | - from localstack.aws.protocol.parser import create_parser |
201 | | - |
202 | 198 | # Use botocore's service model to ensure protocol compatibility |
203 | 199 | # (LocalStack's load_service may return newer protocol versions that don't match the client) |
204 | 200 | service_model = self._get_botocore_service_model(service_name) |
@@ -348,10 +344,7 @@ def _get_botocore_service_model(service_name: str): |
348 | 344 | load_service() to ensure protocol compatibility, as LocalStack may use newer protocol |
349 | 345 | versions (e.g., smithy-rpc-v2-cbor) while clients use older protocols (e.g., query). |
350 | 346 | """ |
351 | | - import botocore.session |
352 | | - from botocore.model import ServiceModel |
353 | | - |
354 | | - session = botocore.session.get_session() |
| 347 | + session = get_botocore_session() |
355 | 348 | loader = session.get_component("data_loader") |
356 | 349 | api_data = loader.load_service_model(service_name, "service-2") |
357 | 350 | return ServiceModel(api_data) |
|
0 commit comments