Skip to content
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

Feat: Support All AWS Partitions #6412

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 17 additions & 11 deletions moto/core/base_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,22 @@ def urls(self) -> Dict[str, str]:
urls = {}
for url_base in url_bases:
# The default URL_base will look like: http://service.[..].amazonaws.com/...
# This extension ensures support for the China regions
cn_url_base = re.sub(r"amazonaws\\?.com$", "amazonaws.com.cn", url_base)
# This extension ensures support for the China & ISO regions
alt_dns_suffixes = {
"cn": "amazonaws.com.cn",
"iso": "c2s.ic.gov",
"isob": "sc2s.sgov.gov",
"isoe": "cloud.adc-e.uk",
"isof": "csp.hci.ic.gov",
}

for url_path, handler in unformatted_paths.items():
url = url_path.format(url_base)
urls[url] = handler
cn_url = url_path.format(cn_url_base)
urls[cn_url] = handler
for dns_suffix in alt_dns_suffixes.values():
alt_url_base = re.sub(r"amazonaws\\?.com$", dns_suffix, url_base)
alt_url = url_path.format(alt_url_base)
urls[alt_url] = handler

return urls

Expand Down Expand Up @@ -188,13 +197,10 @@ def __init__(
self.regions = []
if use_boto3_regions:
sess = Session()
self.regions.extend(sess.get_available_regions(service_name))
self.regions.extend(
sess.get_available_regions(service_name, partition_name="aws-us-gov")
)
self.regions.extend(
sess.get_available_regions(service_name, partition_name="aws-cn")
)
for partition in sess.get_available_partitions():
self.regions.extend(
sess.get_available_regions(service_name, partition_name=partition)
)
self.regions.extend(additional_regions or [])
self._id = str(uuid4())

Expand Down
2 changes: 1 addition & 1 deletion tests/test_awslambda/test_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
boto3.setup_default_session(region_name=_lambda_region)


@pytest.mark.parametrize("region", ["us-west-2", "cn-northwest-1"])
@pytest.mark.parametrize("region", ["us-west-2", "cn-northwest-1", "us-isob-east-1"])
@mock_lambda
def test_lambda_regions(region):
client = boto3.client("lambda", region_name=region)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_stepfunctions/test_stepfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,9 @@ def test_state_machine_get_execution_history_contains_expected_success_events_wh
execution_history["events"].should.equal(expected_events)


@pytest.mark.parametrize("test_region", ["us-west-2", "cn-northwest-1"])
@pytest.mark.parametrize(
"test_region", ["us-west-2", "cn-northwest-1", "us-isob-east-1"]
)
@mock_stepfunctions
def test_stepfunction_regions(test_region):
client = boto3.client("stepfunctions", region_name=test_region)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sts/test_sts.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ def test_federation_token_with_too_long_policy():
)


@pytest.mark.parametrize("region", ["us-west-2", "cn-northwest-1"])
@pytest.mark.parametrize("region", ["us-west-2", "cn-northwest-1", "us-isob-east-1"])
@mock_sts
def test_sts_regions(region):
client = boto3.client("sts", region_name=region)
Expand Down