Skip to content

Commit

Permalink
Fix regexes preventing non-default partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
dfangl committed Aug 1, 2024
1 parent bbcfc4c commit 4271856
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions moto/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from moto.utilities.arns import parse_arn
from moto.utilities.paginator import paginate
from moto.utilities.tagging_service import TaggingService
from moto.utilities.utils import get_partition
from moto.utilities.utils import ARN_PARTITION_REGEX, get_partition

from .utils import _BASE_EVENT_MESSAGE, PAGINATION_MODEL, EventMessageType

Expand Down Expand Up @@ -1675,7 +1675,9 @@ def start_replay(
destination: Dict[str, Any],
) -> Dict[str, Any]:
event_bus_arn = destination["Arn"]
event_bus_arn_pattern = r"^arn:aws:events:[a-zA-Z0-9-]+:\d{12}:event-bus/"
event_bus_arn_pattern = (
rf"{ARN_PARTITION_REGEX}:events:[a-zA-Z0-9-]+:\d{{12}}:event-bus/"
)
if not re.match(event_bus_arn_pattern, event_bus_arn):
raise ValidationException(
"Parameter Destination.Arn is not valid. Reason: Must contain an event bus ARN."
Expand Down
4 changes: 2 additions & 2 deletions moto/resourcegroups/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from moto.core.base_backend import BackendDict, BaseBackend
from moto.core.common_models import BaseModel
from moto.utilities.utils import get_partition
from moto.utilities.utils import ARN_PARTITION_REGEX, get_partition

from .exceptions import BadRequestException

Expand Down Expand Up @@ -246,7 +246,7 @@ def _validate_resource_query(resource_query: Dict[str, str]) -> None:
if not isinstance(stack_identifier, str):
raise invalid_json_exception
if not re.match(
r"^arn:aws:cloudformation:[a-z]{2}-[a-z]+-[0-9]+:[0-9]+:stack/[-0-9A-z]+/[-0-9a-f]+$",
rf"{ARN_PARTITION_REGEX}:cloudformation:[a-z]{{2}}-[a-z]+-[0-9]+:[0-9]+:stack/[-0-9A-z]+/[-0-9a-f]+$",
stack_identifier,
):
raise BadRequestException(
Expand Down

0 comments on commit 4271856

Please sign in to comment.