8000 extend valid regions for Stores to include extended AWS partitions (#… · localstack/localstack@4a8d6af · GitHub
[go: up one dir, main page]

Skip to content
< 10000 header class="HeaderMktg header-logged-out js-details-container js-header Details f4 py-3" role="banner" data-is-top="true" data-color-mode=light data-light-theme=light data-dark-theme=dark>

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4a8d6af

Browse files
authored
extend valid regions for Stores to include extended AWS partitions (#6745)
1 parent 45ba429 commit 4a8d6af

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,5 @@ api_states
6060
/integration/lambdas/golang/handler.zip
6161
/tests/integration/lambdas/golang/handler.zip
6262
tmp/
63+
64+
volume/

localstack/services/stores.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SqsStore(BaseStore):
2828
from threading import RLock
2929
from typing import Any, Type, TypeVar, Union
3030

31-
from boto3 import Session
31+
from localstack.utils.aws.aws_stack import get_valid_regions_for_service
3232

3333
LOCAL_ATTR_PREFIX = "attr_"
3434

@@ -155,7 +155,7 @@ def __init__(
155155
self.validate = validate
156156
self.lock = lock or RLock()
157157

158-
self.valid_regions = Session().get_available_regions(service_name)
158+
self.valid_regions = get_valid_regions_for_service(service_name)
159159

160160
# Keeps track of all cross-region attributes
161161
self._global = {}

tests/unit/test_stores.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from pytest import fixture
23

34
from localstack.services.stores import (
@@ -119,3 +120,20 @@ def test_store_namespacing(self, sample_stores):
119120
== id(sample_stores[account2]._global)
120121
!= id(backend1_ap._global)
121122
)
123+
124+
def test_valid_regions(self):
125+
class SampleStore(BaseStore):
126+
pass
127+
128+
stores = AccountRegionBundle("sns", SampleStore)
129+
account1 = "696969696969"
130+
131+
# assert regular regions work
132+
assert stores[account1]["us-east-1"]
133+
# assert extended regions work
134+
assert stores[account1]["cn-north-1"]
135+
assert stores[account1]["us-gov-west-1"]
136+
# assert invalid regions don't pass validation
137+
with pytest.raises(Exception) as exc:
138+
assert stores[account1]["invalid-region"]
139+
exc.match("not a valid AWS region")

0 commit comments

Comments
 (0)
0