Skip to content

Bug: APIGatewayAuthorizerResponse.from_route_arn drops the ARN partition (aws-cn, aws-us-gov) #8946

Backlog

Description

@THEpranavsomalraju

Expected Behaviour

APIGatewayAuthorizerResponse.from_route_arn should build the policy with the same ARN partition as the methodArn it was given. For arn:aws-cn:execute-api:... the policy resource should start with arn:aws-cn:.

Current Behaviour

The partition is dropped and the policy always uses arn:aws:. For an authorizer in aws-cn or aws-us-gov the returned policy names a resource in a different partition from the method that was invoked. APIGatewayAuthorizerResponseWebSocket.from_route_arn does the same.

Code snippet

from aws_lambda_powertools.utilities.data_classes.api_gateway_authorizer_event import APIGatewayAuthorizerResponse

arn = "arn:aws-cn:execute-api:cn-north-1:123456789012:api123/prod/GET/orders"
policy = APIGatewayAuthorizerResponse.from_route_arn(arn=arn, principal_id="user")
policy.allow_route(http_method="GET", resource="/orders")
print(policy.asdict()["policyDocument"]["Statement"][0]["Resource"])
# ['arn:aws:execute-api:cn-north-1:123456789012:api123/prod/GET/orders']

Possible Solution

parse_api_gateway_arn already returns partition, and the constructor already accepts partition=. Both from_route_arn factories just don't pass it, so it falls back to the default "aws". Passing partition=parsed_arn.partition in both fixes it. I have this with tests and will open a PR.

Steps to Reproduce

Run the snippet above with 3.41.0 or develop (0bbc252).

I ran the snippet and saw the wrong ARN. I don't have an aws-cn or GovCloud account, so I haven't seen the resulting deny from a live API Gateway there; that part follows from the policy resource not matching the invoked method's ARN.

Did you run the reproduction yourself?

Yes, I ran it and saw the failure

Powertools for AWS Lambda (Python) version

3.41.0

AWS Lambda function runtime

3.12

Packaging format used

PyPi

Debugging logs

No response

Activity

  1. boring-cyborg commented on Dec 2, 2026

    @boring-cyborg

    Thanks for opening your first issue here! We'll come back to you as soon as we can.
    In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

  2. powertools-for-aws-oss-automation commented on Dec 2, 2026

    @powertools-for-aws-oss-automation

    Thanks for opening your first issue here! We'll come back to you as soon as we can.
    In the meantime, check out our GitHub Discussions: Join the conversation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions