Skip to content

Commit 7303b2b

Browse files
author
Michael Brewer
authored
Merge branch 'awslabs:develop' into fix-1025-v2
2 parents 814679b + 51ff350 commit 7303b2b

File tree

7 files changed

+43
-11
lines changed

7 files changed

+43
-11
lines changed

.github/workflows/label_pr_on_title.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
github.event.workflow_run.conclusion == 'success' }}
1717
steps:
1818
- name: 'Download artifact'
19-
uses: actions/github-script@v5
19+
uses: actions/github-script@v6
2020
# For security, we only download artifacts tied to the successful PR recording workflow
2121
with:
2222
script: |
@@ -42,7 +42,7 @@ jobs:
4242
- run: unzip pr.zip
4343

4444
- name: 'Label PR based on title'
45-
uses: actions/github-script@v5
45+
uses: actions/github-script@v6
4646
with:
4747
github-token: ${{ secrets.GITHUB_TOKEN }}
4848
# This safely runs in our base repo, not on fork

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ jobs:
109109
keep_files: true
110110
destination_dir: latest/api
111111
- name: Close issues related to this release
112-
uses: actions/github-script@v5
112+
uses: actions/github-script@v6
113113
with:
114114
script: |
115115
const post_release = require('.github/workflows/post_release.js')

aws_lambda_powertools/event_handler/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
Event handler decorators for common Lambda events
33
"""
44

5-
from .api_gateway import ALBResolver, APIGatewayHttpResolver, ApiGatewayResolver, APIGatewayRestResolver
5+
from .api_gateway import ALBResolver, APIGatewayHttpResolver, ApiGatewayResolver, APIGatewayRestResolver, CORSConfig
66
from .appsync import AppSyncResolver
77

8-
__all__ = ["AppSyncResolver", "APIGatewayRestResolver", "APIGatewayHttpResolver", "ALBResolver", "ApiGatewayResolver"]
8+
__all__ = [
9+
"AppSyncResolver",
10+
"APIGatewayRestResolver",
11+
"APIGatewayHttpResolver",
12+
"ALBResolver",
13+
"ApiGatewayResolver",
14+
"CORSConfig",
15+
]

aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def parse_api_gateway_arn(arn: str) -> APIGatewayRouteArn:
6060
api_id=api_gateway_arn_parts[0],
6161
stage=api_gateway_arn_parts[1],
6262
http_method=api_gateway_arn_parts[2],
63-
resource=api_gateway_arn_parts[3] if len(api_gateway_arn_parts) == 4 else "",
63+
# conditional allow us to handle /path/{proxy+} resources, as their length changes.
64+
resource="/".join(api_gateway_arn_parts[3:]) if len(api_gateway_arn_parts) >= 4 else "",
6465
)
6566

6667

docs/core/event_handler/api_gateway.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ You can use **`exception_handler`** decorator with any Python exception. This al
537537
from aws_lambda_powertools import Logger, Tracer
538538
from aws_lambda_powertools.logging import correlation_paths
539539
from aws_lambda_powertools.event_handler import content_types
540-
from aws_lambda_powertools.event_handler import APIGatewayRestResolver, Response
540+
from aws_lambda_powertools.event_handler.api_gateway import APIGatewayRestResolver, Response
541541

542542
tracer = Tracer()
543543
logger = Logger()
@@ -685,7 +685,7 @@ This will ensure that CORS headers are always returned as part of the response w
685685
```python hl_lines="9 11"
686686
from aws_lambda_powertools import Logger, Tracer
687687
from aws_lambda_powertools.logging import correlation_paths
688-
from aws_lambda_powertools.event_handler import APIGatewayRestResolver, CORSConfig
688+
from aws_lambda_powertools.event_handler.api_gateway import APIGatewayRestResolver, CORSConfig
689689

690690
tracer = Tracer()
691691
logger = Logger()

poetry.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/functional/data_classes/test_api_gateway_authorizer.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from aws_lambda_powertools.utilities.data_classes.api_gateway_authorizer_event import (
44
DENY_ALL_RESPONSE,
55
APIGatewayAuthorizerResponse,
6+
APIGatewayAuthorizerTokenEvent,
67
HttpVerb,
78
)
89

@@ -195,3 +196,26 @@ def test_authorizer_response_allow_route_with_underscore(builder: APIGatewayAuth
195196
],
196197
},
197198
}
199+
200+
201+
def test_parse_api_gateway_arn_with_resource():
202+
mock_event = {
203+
"type": "TOKEN",
204+
"methodArn": "arn:aws:execute-api:us-east-2:1234567890:abcd1234/latest/GET/path/part/part/1",
205+
"authorizationToken": "Bearer TOKEN",
206+
}
207+
event = APIGatewayAuthorizerTokenEvent(mock_event)
208+
event_arn = event.parsed_arn
209+
assert event_arn.resource == "path/part/part/1"
210+
211+
authorizer_policy = APIGatewayAuthorizerResponse(
212+
principal_id="fooPrinciple",
213+
region=event_arn.region,
214+
aws_account_id=event_arn.aws_account_id,
215+
api_id=event_arn.api_id,
216+
stage=event_arn.stage,
217+
)
218+
authorizer_policy.allow_route(http_method=event_arn.http_method, resource=event_arn.resource)
219+
response = authorizer_policy.asdict()
220+
221+
assert mock_event["methodArn"] == response["policyDocument"]["Statement"][0]["Resource"][0]

0 commit comments

Comments
 (0)