8000 Partially update SQS to use the new config · localstack/localstack@6e58a00 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6e58a00

Browse files
committed
Partially update SQS to use the new config
The logic seems a little fragmented - the default is to use the `Host` request header, but then some circumstances can partially override this with new behaviour.
1 parent c935265 commit 6e58a00

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

localstack/services/sqs/models.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from queue import PriorityQueue
1010
from typing import Dict, NamedTuple, Optional, Set
1111

12-
from localstack import config, constants
12+
from localstack import config
1313
from localstack.aws.api import RequestContext
1414
from localstack.aws.api.sqs import (
1515
InvalidAttributeName,
@@ -21,7 +21,7 @@
2121
ReceiptHandleIsInvalid,
2222
TagMap,
2323
)
24-
from localstack.config import external_service_url
24+
from localstack.config import get_protocol
2525
from localstack.services.sqs import constants as sqs_constants
2626
from localstack.services.sqs.exceptions import (
2727
InvalidAttributeValue,
@@ -35,6 +35,7 @@
3535
)
3636
from localstack.services.stores import AccountRegionBundle, BaseStore, LocalAttribute
3737
from localstack.utils.time import now
38+
from localstack.utils.urls import localstack_host
3839

3940
LOG = logging.getLogger(__name__)
4041

@@ -249,13 +250,18 @@ def url(self, context: RequestContext) -> str:
249250
# or us-east-2.queue.localhost.localstack.cloud:4566/000000000000/my-queue
250251
region = "" if self.region == "us-east-1" else self.region + "."
251252
scheme = context.request.scheme
252-
host_url = f"{scheme}://{region}queue.{constants.LOCALHOST_HOSTNAME}:{config.EDGE_PORT}"
253+
254+
host_definition = localstack_host(use_localhost_cloud=True)
255+
host_url = f"{scheme}://{region}queue.{host_definition.host_and_port()}"
253256
elif config.SQS_ENDPOINT_STRATEGY == "path":
254257
# https?://localhost:4566/queue/us-east-1/00000000000/my-queue (us-east-1)
255258
host_url = f"{context.request.host_url}/queue/{self.region}"
256259
else:
257260
if config.SQS_PORT_EXTERNAL:
258-
host_url = external_service_url("sqs")
261+
host_definition = localstack_host(
262+
use_hostname_external=True, custom_port=config.SQS_PORT_EXTERNAL
263+
)
264+
return f"{get_protocol()}://{host_definition.host_and_port()}"
259265

260266
return "{host}/{account_id}/{name}".format(
261267
host=host_url.rstrip("/"),

tests/integration/test_network_configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ def test_off_strategy(self, monkeypatch, sqs_create_queue, patch_hostnames):
170170
queue_url = sqs_create_queue()
171171

172172
assert external_hostname in queue_url
173+
assert external_port in queue_url
173174

174175
assert localstack_hostname not in queue_url
175176

0 commit comments

Comments
 (0)
0