-
Notifications
You must be signed in to change notification settings - Fork 421
APIGatewayRouteArn does not work with a proxy resource. #1047
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
Comments
Thanks. I will have a look |
@brysontyrrell can you add a sample event to make it easier for the failing test :-) |
@brysontyrrell this fix will shift the error to the if not self._resource_pattern.match(resource):
> raise ValueError(f"Invalid resource path: {resource}. Path should match {self.path_regex}")
E ValueError: Invalid resource path: name/{proxy+}. Path should match ^[/.a-zA-Z0-9-_\*]+$ |
@brysontyrrell i have a partial fix for the arn parsing: But this will still fail to handle |
@michaelbrewer sorry for not including an example event. The path does not actually contain {
"type": "TOKEN",
"methodArn": "arn:aws:execute-api:us-east-2:1234567890:abcd1234/latest/GET/path/part/part/1",
"authorizationToken": "Bearer TOKEN"
} In the above my API Gateway route may be configured to have |
Ok, @brysontyrrell then the PR should be valid! |
Thanks everyone, just merged and hope to make a patch release with this and another fix by end of the week. I suspect we might not need this hard check in case additional changes occur to ARNs, but it's also hard to predict whether this will happen - leaving as-is and will add to the maintenance list to revisit in the future with more time to test unhappy paths. |
This is now released under 1.25.2 version! |
If there is an AWS regex or ARN parser then we can incorporate it into the tests. Otherwise a general purpose ARN parser could be used in many other places. |
What were you trying to accomplish?
API Gateway with a Lambda Authorizer.
Path is
/name/{proxy+}
.Allowing the route requested in the policy using
APIGatewayAuthorizerResponse
:Expected Behavior
The policy contains the correct resource path and can be returned to API Gateway.
Current Behavior
The resource is blank which causes this error to be thrown:
I tracked it down to this line:
https://github.com/awslabs/aws-lambda-powertools-python/blame/develop/aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py#L63
I don't know what the reason was for a hard check on the length of the parts for the path. @michaelbrewer could you share some light there?
Possible Solution
This issue is resolved with the following modification:
Steps to Reproduce (for bugs)
Create a proxy resource and setup a Lambda Authorizer using Powertools as described above.
Environment
The text was updated successfully, but these errors were encountered: