diff --git a/moto/apigateway/models.py b/moto/apigateway/models.py index eb7935f33..bccbbdd7d 100644 --- a/moto/apigateway/models.py +++ b/moto/apigateway/models.py @@ -1734,7 +1734,7 @@ class APIGatewayBackend(BaseBackend): if not path_part: # We're attempting to create the default resource, which already exists. return api.default - if not re.match("^\\{?[a-zA-Z0-9._-]+\\+?\\}?$", path_part): + if not re.match("^\\{?[a-zA-Z0-9._\\-\\:]+\\+?\\}?$", path_part): raise InvalidResourcePathException() return api.add_child(path=path_part, parent_id=parent_resource_id) diff --git a/tests/test_apigateway/test_apigateway.py b/tests/test_apigateway/test_apigateway.py index 911850a90..85129f7b9 100644 --- a/tests/test_apigateway/test_apigateway.py +++ b/tests/test_apigateway/test_apigateway.py @@ -272,7 +272,7 @@ def test_create_resource__validate_name(): ]["id"] invalid_names = ["/users", "users/", "users/{user_id}", "us{er", "us+er"] - valid_names = ["users", "{user_id}", "{proxy+}", "user_09", "good-dog"] + valid_names = ["users", "{user_id}", "{proxy+}", "{pro:xy+}", "us:er_0-9"] # All invalid names should throw an exception for name in invalid_names: with pytest.raises(ClientError) as ex: