8000 Extend valid regions for Stores to include extended AWS partitions by whummer · Pull Request #6745 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

Extend valid regions for Stores to include extended AWS partitions #6745

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 1 commit into from
Aug 24, 2022
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
extend valid regions for Stores to include extended AWS partitions
  • Loading branch information
whummer committed Aug 24, 2022
commit 00769872bf2e41038878d2f0fcc063d33fbc75f4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ api_states
/integration/lambdas/golang/handler.zip
/tests/integration/lambdas/golang/handler.zip
tmp/

volume/
4 changes: 2 additions & 2 deletions localstack/services/stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SqsStore(BaseStore):
from threading import RLock
from typing import Any, Type, TypeVar, Union

from boto3 import Session
from localstack.utils.aws.aws_stack import get_valid_regions_for_service

LOCAL_ATTR_PREFIX = "attr_"

Expand Down Expand Up @@ -155,7 +155,7 @@ def __init__(
self.validate = validate
self.lock = lock or RLock()

self.valid_regions = Session().get_available_regions(service_name)
self.valid_regions = get_valid_regions_for_service(service_name)

# Keeps track of all cross-region attributes
self._global = {}
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/test_stores.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
from pytest import fixture

from localstack.services.stores import (
Expand Down Expand Up @@ -119,3 +120,20 @@ def test_store_namespacing(self, sample_stores):
== id(sample_stores[account2]._global)
!= id(backend1_ap._global)
)

def test_valid_regions(self):
class SampleStore(BaseStore):
pass

stores = AccountRegionBundle("sns", SampleStore)
account1 = "696969696969"

# assert regular regions work
assert stores[account1]["us-east-1"]
# assert extended regions work
assert stores[account1]["cn-north-1"]
assert stores[account1]["us-gov-west-1"]
# assert invalid regions don't pass validation
with pytest.raises(Exception) as exc:
assert stores[account1]["invalid-region"]
exc.match("not a valid AWS region")
0