|
17 | 17 | from localstack.aws.api import HttpRequest |
18 | 18 | from localstack.aws.protocol.parser import create_parser |
19 | 19 | from localstack.aws.spec import load_service |
20 | | -from localstack.config import get_edge_url |
| 20 | +from localstack.config import internal_service_url |
21 | 21 | from localstack.constants import AWS_REGION_US_EAST_1, DOCKER_IMAGE_NAME_PRO |
22 | 22 | from localstack.http import Request |
23 | 23 | from localstack.utils.aws.aws_responses import requests_response |
|
30 | 30 | from localstack.utils.net import get_free_tcp_port |
31 | 31 | from localstack.utils.server.http2_server import run_server |
32 | 32 | from localstack.utils.serving import Server |
33 | | -from localstack.utils.strings import short_uid, to_str, truncate |
34 | | -from localstack_ext.bootstrap.licensing import ENV_LOCALSTACK_API_KEY |
| 33 | +from localstack.utils.strings import short_uid, to_bytes, to_str, truncate |
| 34 | +from localstack_ext.bootstrap.licensingv2 import ENV_LOCALSTACK_API_KEY |
35 | 35 | from requests import Response |
36 | 36 |
|
37 | 37 | from aws_replicator.client.utils import truncate_content |
@@ -138,7 +138,7 @@ def register_in_instance(self): |
138 | 138 | port = getattr(self, "port", None) |
139 | 139 | if not port: |
140 | 140 | raise Exception("Proxy currently not running") |
141 | | - url = f"{get_edge_url()}{HANDLER_PATH_PROXIES}" |
| 141 | + url = f"{internal_service_url()}{HANDLER_PATH_PROXIES}" |
142 | 142 | data = AddProxyRequest(port=port, config=self.config) |
143 | 143 | try: |
144 | 144 | response = requests.post(url, json=data) |
@@ -214,13 +214,22 @@ def _adjust_request_dict(self, service_name: str, request_dict: Dict): |
214 | 214 | '<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">' |
215 | 215 | f"<LocationConstraint>{region}</LocationConstraint></CreateBucketConfiguration>" |
216 | 216 | ) |
| 217 | + |
217 | 218 | if service_name == "sqs" and isinstance(req_body, dict): |
218 | 219 | account_id = self._query_account_id_from_aws() |
219 | 220 | if "QueueUrl" in req_body: |
220 | 221 | queue_name = req_body["QueueUrl"].split("/")[-1] |
221 | 222 | req_body["QueueUrl"] = f"https://queue.amazonaws.com/{account_id}/{queue_name}" |
222 | 223 | if "QueueOwnerAWSAccountId" in req_body: |
223 | 224 | req_body["QueueOwnerAWSAccountId"] = account_id |
| 225 | + if service_name == "sqs" and request_dict.get("url"): |
| 226 | + req_json = run_safe(lambda: json.loads(body_str)) or {} |
| 227 | + account_id = self._query_account_id_from_aws() |
| 228 | + queue_name = req_json.get("QueueName") |
| 229 | + if account_id and queue_name: |
| 230 | + request_dict["url"] = f"https://queue.amazonaws.com/{account_id}/{queue_name}" |
| 231 | + req_json["QueueOwnerAWSAccountId"] = account_id |
| 232 | + request_dict["body"] = to_bytes(json.dumps(req_json)) |
224 | 233 |
|
225 | 234 | def _fix_headers(self, request: HttpRequest, service_name: str): |
226 | 235 | if service_name == "s3": |
|
0 commit comments