8000 Give precedence to region override over config by viren-nadkarni · Pull Request #8997 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

Give precedence to region override over config #8997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 31, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Give precedence to region override over the fallback in config
  • Loading branch information
viren-nadkarni committed Aug 28, 2023
commit f64b7859ce94626d884d9d19ff3b347fb4290269
9 changes: 9 additions & 0 deletions localstack/aws/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from localstack import config as localstack_config
from localstack.constants import (
AWS_REGION_US_EAST_1,
INTERNAL_AWS_ACCESS_KEY_ID,
INTERNAL_AWS_SECRET_ACCESS_KEY,
MAX_POOL_CONNECTIONS,
Expand Down Expand Up @@ -465,6 +466,14 @@ def get_client(
else:
config = self._config.merge(config)

# Boto has an odd behaviour when using a non-default (any other region than us-east-1) in config
# If the region in arg is non-default, it gives the arg the precedence
# But if the region in arg is default (us-east-1), it gives precedence to one in config
# Below: always give precedence to arg region
if config and config.region_name != AWS_REGION_US_EAST_1:
if region_name == AWS_REGION_US_EAST_1:
config = config.merge(Config(region_name=region_name))

endpoint_url = endpoint_url or get_local_service_url(service_name)
if service_name == "s3":
if re.match(r"https?://localhost(:[0-9]+)?", endpoint_url):
Expand Down
0