@@ -21,8 +21,9 @@ def __init__(
21
21
stage : str ,
22
22
http_method : str ,
23
23
resource : str ,
24
+ partition : str = "aws" ,
24
25
):
25
- self .partition = "aws"
26
+ self .partition = partition
26
27
self .region = region
27
28
self .aws_account_id = aws_account_id
28
29
self .api_id = api_id
@@ -55,6 +56,7 @@ def parse_api_gateway_arn(arn: str) -> APIGatewayRouteArn:
55
56
arn_parts = arn .split (":" )
56
57
api_gateway_arn_parts = arn_parts [5 ].split ("/" )
57
58
return APIGatewayRouteArn (
59
+ partition = arn_parts [1 ],
58
60
region = arn_parts [3 ],
59
61
aws_account_id = arn_parts [4 ],
60
62
api_id = api_gateway_arn_parts [0 ],
@@ -369,6 +371,7 @@ def __init__(
369
371
stage : str ,
370
372
context : Optional [Dict ] = None ,
371
373
usage_identifier_key : Optional [str ] = None ,
374
+ partition : str = "aws" ,
372
375
):
373
376
"""
374
377
Parameters
@@ -401,6 +404,9 @@ def __init__(
401
404
If the API uses a usage plan (the apiKeySource is set to `AUTHORIZER`), the Lambda authorizer function
402
405
must return one of the usage plan's API keys as the usageIdentifierKey property value.
403
406
> **Note:** This only applies for REST APIs.
407
+ partition: str, optional
408
+ Optional, arn partition.
409
+ See https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html
404
410
"""
405
411
self .principal_id = principal_id
406
412
self .region = region
@@ -412,6 +418,7 @@ def __init__(
412
418
self ._allow_routes : List [Dict ] = []
413
419
self ._deny_routes : List [Dict ] = []
414
420
self ._resource_pattern = re .compile (self .path_regex )
421
+ self .partition = partition
415
422
416
423
@staticmethod
417
424
def from_route_arn (
@@ -443,7 +450,7 @@ def _add_route(self, effect: str, http_method: str, resource: str, conditions: O
443
450
raise ValueError (f"Invalid resource path: { resource } . Path should match { self .path_regex } " )
444
451
445
452
resource_arn = APIGatewayRouteArn (
446
- self .region , self .aws_account_id , self .api_id , self .stage , http_method , resource
453
+ self .region , self .aws_account_id , self .api_id , self .stage , http_method , resource , self . partition
447
454
).arn
448
455
449
456
route = {"resourceArn" : resource_arn , "conditions" : conditions }
0 commit comments