Skip to content

Commit 3cd593c

Browse files
Merge branch 'develop' into disablemetrics
2 parents 9defaf7 + a4ec359 commit 3cd593c

File tree

13 files changed

+517
-69
lines changed

13 files changed

+517
-69
lines changed

Diff for: CHANGELOG.md

+33-24
Original file line numberDiff line numberDiff line change
@@ -40,50 +40,59 @@
4040

4141
## Maintenance
4242

43+
* **ci:** new pre-release 3.5.1a4 ([#6018](https://github.com/aws-powertools/powertools-lambda-python/issues/6018))
4344
* **ci:** new pre-release 3.5.1a0 ([#5945](https://github.com/aws-powertools/powertools-lambda-python/issues/5945))
45+
* **ci:** new pre-release 3.5.1a3 ([#5998](https://github.com/aws-powertools/powertools-lambda-python/issues/5998))
4446
* **ci:** new pre-release 3.5.1a1 ([#5954](https://github.com/aws-powertools/powertools-lambda-python/issues/5954))
47+
* **ci:** new pre-release 3.5.1a8 ([#6061](https://github.com/aws-powertools/powertools-lambda-python/issues/6061))
4548
* **ci:** install & configure mkdocstrings plugin ([#5959](https://github.com/aws-powertools/powertools-lambda-python/issues/5959))
4649
* **ci:** new pre-release 3.5.1a7 ([#6044](https://github.com/aws-powertools/powertools-lambda-python/issues/6044))
50+
* **ci:** remove pdoc3 library ([#6024](https://github.com/aws-powertools/powertools-lambda-python/issues/6024))
51+
* **ci:** new pre-release 3.5.1a5 ([#6026](https://github.com/aws-powertools/powertools-lambda-python/issues/6026))
52+
* **ci:** add new script to bump Lambda layer version ([#6001](https://github.com/aws-powertools/powertools-lambda-python/issues/6001))
4753
* **ci:** new pre-release 3.5.1a2 ([#5970](https://github.com/aws-powertools/powertools-lambda-python/issues/5970))
48-
* **ci:** new pre-release 3.5.1a3 ([#5998](https://github.com/aws-powertools/powertools-lambda-python/issues/5998))
4954
* **ci:** new pre-release 3.5.1a6 ([#6033](https://github.com/aws-powertools/powertools-lambda-python/issues/6033))
50-
* **ci:** add new script to bump Lambda layer version ([#6001](https://github.com/aws-powertools/powertools-lambda-python/issues/6001))
51-
* **ci:** new pre-release 3.5.1a5 ([#6026](https://github.com/aws-powertools/powertools-lambda-python/issues/6026))
52-
* **ci:** new pre-release 3.5.1a4 ([#6018](https://github.com/aws-powertools/powertools-lambda-python/issues/6018))
53-
* **ci:** remove pdoc3 library ([#6024](https://github.com/aws-powertools/powertools-lambda-python/issues/6024))
55+
* **deps:** bump zgosalvez/github-actions-ensure-sha-pinned-actions from 3.0.18 to 3.0.20 ([#5977](https://github.com/aws-powertools/powertools-lambda-python/issues/5977))
5456
* **deps:** bump release-drafter/release-drafter from 6.0.0 to 6.1.0 ([#5976](https://github.com/aws-powertools/powertools-lambda-python/issues/5976))
55-
* **deps:** bump docker/setup-buildx-action from 3.8.0 to 3.9.0 ([#6042](https://github.com/aws-powertools/powertools-lambda-python/issues/6042))
56-
* **deps:** bump actions/setup-python from 5.3.0 to 5.4.0 ([#5960](https://github.com/aws-powertools/powertools-lambda-python/issues/5960))
57-
* **deps:** bump docker/setup-qemu-action from 3.2.0 to 3.3.0 ([#5961](https://github.com/aws-powertools/powertools-lambda-python/issues/5961))
58-
* **deps:** bump codecov/codecov-action from 5.1.2 to 5.3.1 ([#5964](https://github.com/aws-powertools/powertools-lambda-python/issues/5964))
59-
* **deps:** bump squidfunk/mkdocs-material from `471695f` to `7e841df` in /docs ([#6012](https://github.com/aws-powertools/powertools-lambda-python/issues/6012))
60-
* **deps:** bump actions/setup-node from 4.1.0 to 4.2.0 ([#5963](https://github.com/aws-powertools/powertools-lambda-python/issues/5963))
57+
* **deps:** bump aws-actions/configure-aws-credentials from 4.0.2 to 4.0.3 ([#5975](https://github.com/aws-powertools/powertools-lambda-python/issues/5975))
6158
* **deps:** bump actions/upload-artifact from 4.5.0 to 4.6.0 ([#5962](https://github.com/aws-powertools/powertools-lambda-python/issues/5962))
59+
* **deps:** bump actions/setup-node from 4.1.0 to 4.2.0 ([#5963](https://github.com/aws-powertools/powertools-lambda-python/issues/5963))
60+
* **deps:** bump pypa/gh-action-pypi-publish from 1.12.3 to 1.12.4 ([#5980](https://github.com/aws-powertools/powertools-lambda-python/issues/5980))
61+
* **deps:** bump docker/setup-qemu-action from 3.2.0 to 3.3.0 ([#5961](https://github.com/aws-powertools/powertools-lambda-python/issues/5961))
62+
* **deps:** bump docker/setup-buildx-action from 3.8.0 to 3.9.0 ([#6042](https://github.com/aws-powertools/powertools-lambda-python/issues/6042))
6263
* **deps:** bump docker/setup-qemu-action from 3.3.0 to 3.4.0 ([#6043](https://github.com/aws-powertools/powertools-lambda-python/issues/6043))
63-
* **deps:** bump aws-actions/configure-aws-credentials from 4.0.2 to 4.0.3 ([#5975](https://github.com/aws-powertools/powertools-lambda-python/issues/5975))
64-
* **deps:** bump squidfunk/mkdocs-material from `41942f7` to `471695f` in /docs ([#5979](https://github.com/aws-powertools/powertools-lambda-python/issues/5979))
6564
* **deps:** bump actions/setup-go from 5.2.0 to 5.3.0 ([#5978](https://github.com/aws-powertools/powertools-lambda-python/issues/5978))
66-
* **deps:** bump pypa/gh-action-pypi-publish from 1.12.3 to 1.12.4 ([#5980](https://github.com/aws-powertools/powertools-lambda-python/issues/5980))
67-
* **deps:** bump zgosalvez/github-actions-ensure-sha-pinned-actions from 3.0.18 to 3.0.20 ([#5977](https://github.com/aws-powertools/powertools-lambda-python/issues/5977))
65+
* **deps:** bump squidfunk/mkdocs-material from `41942f7` to `471695f` in /docs ([#5979](https://github.com/aws-powertools/powertools-lambda-python/issues/5979))
66+
* **deps:** bump actions/setup-python from 5.3.0 to 5.4.0 ([#5960](https://github.com/aws-powertools/powertools-lambda-python/issues/5960))
67+
* **deps:** bump squidfunk/mkdocs-material from `7e841df` to `c62453b` in /docs ([#6052](https://github.com/aws-powertools/powertools-lambda-python/issues/6052))
68+
* **deps:** bump squidfunk/mkdocs-material from `471695f` to `7e841df` in /docs ([#6012](https://github.com/aws-powertools/powertools-lambda-python/issues/6012))
69+
* **deps:** bump codecov/codecov-action from 5.1.2 to 5.3.1 ([#5964](https://github.com/aws-powertools/powertools-lambda-python/issues/5964))
70+
* **deps-dev:** bump aws-cdk-aws-lambda-python-alpha from 2.178.0a0 to 2.178.1a0 ([#6048](https://github.com/aws-powertools/powertools-lambda-python/issues/6048))
71+
* **deps-dev:** bump mkdocstrings-python from 1.14.4 to 1.14.5 ([#6032](https://github.com/aws-powertools/powertools-lambda-python/issues/6032))
72+
* **deps-dev:** bump mkdocs-material from 9.6.1 to 9.6.2 ([#6009](https://github.com/aws-powertools/powertools-lambda-python/issues/6009))
73+
* **deps-dev:** bump boto3-stubs from 1.36.10 to 1.36.11 ([#6010](https://github.com/aws-powertools/powertools-lambda-python/issues/6010))
74+
* **deps-dev:** bump boto3-stubs from 1.36.10 to 1.36.12 ([#6014](https://github.com/aws-powertools/powertools-lambda-python/issues/6014))
6875
* **deps-dev:** bump mkdocstrings-python from 1.14.2 to 1.14.4 ([#6025](https://github.com/aws-powertools/powertools-lambda-python/issues/6025))
76+
* **deps-dev:** bump cfn-lint from 1.23.1 to 1.24.0 ([#6030](https://github.com/aws-powertools/powertools-lambda-python/issues/6030))
77+
* **deps-dev:** bump cdklabs-generative-ai-cdk-constructs from 0.1.290 to 0.1.291 ([#6031](https://github.com/aws-powertools/powertools-lambda-python/issues/6031))
6978
* **deps-dev:** bump boto3-stubs from 1.36.12 to 1.36.14 ([#6029](https://github.com/aws-powertools/powertools-lambda-python/issues/6029))
7079
* **deps-dev:** bump black from 24.10.0 to 25.1.0 ([#5968](https://github.com/aws-powertools/powertools-lambda-python/issues/5968))
7180
* **deps-dev:** bump ruff from 0.9.3 to 0.9.4 ([#5969](https://github.com/aws-powertools/powertools-lambda-python/issues/5969))
7281
* **deps-dev:** bump mypy from 1.14.1 to 1.15.0 ([#6028](https://github.com/aws-powertools/powertools-lambda-python/issues/6028))
7382
* **deps-dev:** bump cfn-lint from 1.22.7 to 1.23.1 ([#5967](https://github.com/aws-powertools/powertools-lambda-python/issues/5967))
74-
* **deps-dev:** bump cdklabs-generative-ai-cdk-constructs from 0.1.290 to 0.1.291 ([#6031](https://github.com/aws-powertools/powertools-lambda-python/issues/6031))
75-
* **deps-dev:** bump isort from 5.13.2 to 6.0.0 ([#5965](https://github.com/aws-powertools/powertools-lambda-python/issues/5965))
76-
* **deps-dev:** bump cfn-lint from 1.23.1 to 1.24.0 ([#6030](https://github.com/aws-powertools/powertools-lambda-python/issues/6030))
77-
* **deps-dev:** bump mkdocstrings-python from 1.14.4 to 1.14.5 ([#6032](https://github.com/aws-powertools/powertools-lambda-python/issues/6032))
78-
* **deps-dev:** bump mkdocs-material from 9.5.50 to 9.6.1 ([#5966](https://github.com/aws-powertools/powertools-lambda-python/issues/5966))
7983
* **deps-dev:** bump mkdocstrings-python from 1.13.0 to 1.14.2 ([#6011](https://github.com/aws-powertools/powertools-lambda-python/issues/6011))
80-
* **deps-dev:** bump mkdocs-material from 9.6.1 to 9.6.2 ([#6009](https://github.com/aws-powertools/powertools-lambda-python/issues/6009))
84+
* **deps-dev:** bump isort from 5.13.2 to 6.0.0 ([#5965](https://github.com/aws-powertools/powertools-lambda-python/issues/5965))
85+
* **deps-dev:** bump aws-cdk-lib from 2.177.0 to 2.178.0 ([#6038](https://github.com/aws-powertools/powertools-lambda-python/issues/6038))
8186
* **deps-dev:** bump ruff from 0.9.4 to 0.9.5 ([#6039](https://github.com/aws-powertools/powertools-lambda-python/issues/6039))
82-
* **deps-dev:** bump boto3-stubs from 1.36.10 to 1.36.11 ([#6010](https://github.com/aws-powertools/powertools-lambda-python/issues/6010))
87+
* **deps-dev:** bump mkdocs-material from 9.5.50 to 9.6.1 ([#5966](https://github.com/aws-powertools/powertools-lambda-python/issues/5966))
8388
* **deps-dev:** bump aws-cdk-aws-lambda-python-alpha from 2.177.0a0 to 2.178.0a0 ([#6041](https://github.com/aws-powertools/powertools-lambda-python/issues/6041))
8489
* **deps-dev:** bump aws-cdk from 2.177.0 to 2.178.0 ([#6040](https://github.com/aws-powertools/powertools-lambda-python/issues/6040))
85-
* **deps-dev:** bump boto3-stubs from 1.36.10 to 1.36.12 ([#6014](https://github.com/aws-powertools/powertools-lambda-python/issues/6014))
86-
* **deps-dev:** bump aws-cdk-lib from 2.177.0 to 2.178.0 ([#6038](https://github.com/aws-powertools/powertools-lambda-python/issues/6038))
90+
* **deps-dev:** bump aws-cdk from 2.178.0 to 2.178.1 ([#6053](https://github.com/aws-powertools/powertools-lambda-python/issues/6053))
91+
* **deps-dev:** bump aws-cdk-lib from 2.178.0 to 2.178.1 ([#6047](https://github.com/aws-powertools/powertools-lambda-python/issues/6047))
92+
* **deps-dev:** bump boto3-stubs from 1.36.14 to 1.36.15 ([#6049](https://github.com/aws-powertools/powertools-lambda-python/issues/6049))
93+
* **deps-dev:** bump cdklabs-generative-ai-cdk-constructs from 0.1.291 to 0.1.292 ([#6051](https://github.com/aws-powertools/powertools-lambda-python/issues/6051))
94+
* **deps-dev:** bump mkdocstrings-python from 1.14.5 to 1.14.6 ([#6050](https://github.com/aws-powertools/powertools-lambda-python/issues/6050))
95+
* **deps-dev:** bump boto3-stubs from 1.36.14 to 1.36.16 ([#6057](https://github.com/aws-powertools/powertools-lambda-python/issues/6057))
8796
* **docs:** enable privacy plugin in docs ([#6036](https://github.com/aws-powertools/powertools-lambda-python/issues/6036))
8897

8998

Diff for: aws_lambda_powertools/shared/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Exposes version constant to avoid circular dependencies."""
22

3-
VERSION = "3.5.1a7"
3+
VERSION = "3.5.1a8"

Diff for: aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py

+157-16
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import warnings
66
from typing import Any, overload
77

8-
from typing_extensions import deprecated
8+
from typing_extensions import deprecated, override
99

1010
from aws_lambda_powertools.utilities.data_classes.common import (
1111
BaseRequestContext,
@@ -28,9 +28,10 @@ def __init__(
2828
aws_account_id: str,
2929
api_id: str,
3030
stage: str,
31-
http_method: str,
31+
http_method: str | None,
3232
resource: str,
3333
partition: str = "aws",
34+
is_websocket_authorizer: bool = False,
3435
):
3536
self.partition = partition
3637
self.region = region
@@ -40,39 +41,54 @@ def __init__(
4041
self.http_method = http_method
4142
# Remove matching "/" from `resource`.
4243
self.resource = resource.lstrip("/")
44+
self.is_websocket_authorizer = is_websocket_authorizer
4345

4446
@property
4547
def arn(self) -> str:
4648
"""Build an arn from its parts
4749
eg: arn:aws:execute-api:us-east-1:123456789012:abcdef123/test/GET/request"""
48-
return (
49-
f"arn:{self.partition}:execute-api:{self.region}:{self.aws_account_id}:{self.api_id}/{self.stage}/"
50-
f"{self.http_method}/{self.resource}"
51-
)
50+
base_arn = f"arn:{self.partition}:execute-api:{self.region}:{self.aws_account_id}:{self.api_id}/{self.stage}"
51+
52+
if not self.is_websocket_authorizer:
53+
return f"{base_arn}/{self.http_method}/{self.resource}"
54+
else:
55+
return f"{base_arn}/{self.resource}"
5256

5357

54-
def parse_api_gateway_arn(arn: str) -> APIGatewayRouteArn:
58+
def parse_api_gateway_arn(arn: str, is_websocket_authorizer: bool = False) -> APIGatewayRouteArn:
5559
"""Parses a gateway route arn as a APIGatewayRouteArn class
5660
5761
Parameters
5862
----------
5963
arn : str
6064
ARN string for a methodArn or a routeArn
65+
is_websocket_authorizer: bool
66+
If it's a API Gateway Websocket
67+
6168
Returns
6269
-------
6370
APIGatewayRouteArn
6471
"""
6572
arn_parts = arn.split(":")
6673
api_gateway_arn_parts = arn_parts[5].split("/")
74+
75+
if not is_websocket_authorizer:
76+
http_method = api_gateway_arn_parts[2]
77+
resource = "/".join(api_gateway_arn_parts[3:]) if len(api_gateway_arn_parts) >= 4 else ""
78+
else:
79+
http_method = None
80+
resource = "/".join(api_gateway_arn_parts[2:])
81+
6782
return APIGatewayRouteArn(
6883
partition=arn_parts[1],
6984
region=arn_parts[3],
7085
aws_account_id=arn_parts[4],
7186
api_id=api_gateway_arn_parts[0],
7287
stage=api_gateway_arn_parts[1],
73-
http_method=api_gateway_arn_parts[2],
88+
http_method=http_method,
7489
# conditional allow us to handle /path/{proxy+} resources, as their length changes.
75-
resource="/".join(api_gateway_arn_parts[3:]) if len(api_gateway_arn_parts) >= 4 else "",
90+
resource=resource,
91+
is_websocket_authorizer=is_websocket_authorizer,
7692
)
7793

7894

@@ -512,13 +528,14 @@ def _add_route(self, effect: str, http_method: str, resource: str, conditions: l
512528
raise ValueError(f"Invalid resource path: {resource}. Path should match {self.path_regex}")
513529

514530
resource_arn = APIGatewayRouteArn(
515-
self.region,
516-
self.aws_account_id,
517-
self.api_id,
518-
self.stage,
519-
http_method,
520-
resource,
521-
self.partition,
531+
region=self.region,
532+
aws_account_id=self.aws_account_id,
533+
api_id=self.api_id,
534+
stage=self.stage,
535+
http_method=http_method,
536+
resource=resource,
537+
partition=self.partition,
538+
is_websocket_authorizer=False,
522539
).arn
523540

524541
route = {"resourceArn": resource_arn, "conditions": conditions}
@@ -617,3 +634,127 @@ def asdict(self) -> dict[str, Any]:
617634
response["context"] = self.context
618635

619636
return response
637+
638+
639+
class APIGatewayAuthorizerResponseWebSocket(APIGatewayAuthorizerResponse):
640+
"""The IAM Policy Response required for API Gateway WebSocket APIs
641+
642+
Based on: - https://github.com/awslabs/aws-apigateway-lambda-authorizer-blueprints/blob/\
643+
master/blueprints/python/api-gateway-authorizer-python.py
644+
645+
Documentation:
646+
-------------
647+
- https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html
648+
- https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html
649+
"""
650+
651+
@staticmethod
652+
def from_route_arn(
653+
arn: str,
654+
principal_id: str,
655+
context: dict | None = None,
656+
usage_identifier_key: str | None = None,
657+
) -> APIGatewayAuthorizerResponseWebSocket:
658+
parsed_arn = parse_api_gateway_arn(arn, is_websocket_authorizer=True)
659+
return APIGatewayAuthorizerResponseWebSocket(
660+
principal_id,
661+
parsed_arn.region,
662+
parsed_arn.aws_account_id,
663+
parsed_arn.api_id,
664+
parsed_arn.stage,
665+
context,
666+
usage_identifier_key,
667+
)
668+
669+
# Note: we need ignore[override] because we are removing the http_method field
670+
@override
671+
def _add_route(self, effect: str, resource: str, conditions: list[dict] | None = None): # type: ignore[override]
672+
"""Adds a route to the internal lists of allowed or denied routes. Each object in
673+
the internal list contains a resource ARN and a condition statement. The condition
674+
statement can be null."""
675+
resource_arn = APIGatewayRouteArn(
676+
region=self.region,
677+
aws_account_id=self.aws_account_id,
678+
api_id=self.api_id,
679+
stage=self.stage,
680+
http_method=None,
681+
resource=resource,
682+
partition=self.partition,
683+
is_websocket_authorizer=True,
684+
).arn
685+
686+
route = {"resourceArn": resource_arn, "conditions": conditions}
687+
688+
if effect.lower() == "allow":
689+
self._allow_routes.append(route)
690+
else: # deny
691+
self._deny_routes.append(route)
692+
693+
@override
694+
def allow_all_routes(self):
695+
"""Adds a '*' allow to the policy to authorize access to all methods of an API"""
696+
self._add_route(effect="Allow", resource="*")
697+
698+
@override
699+
def deny_all_routes(self):
700+
"""Adds a '*' allow to the policy to deny access to all methods of an API"""
701+
702+
self._add_route(effect="Deny", resource="*")
703+
704+
# Note: we need ignore[override] because we are removing the http_method field
705+
@override
706+
def allow_route(self, resource: str, conditions: list[dict] | None = None): # type: ignore[override]
707+
"""
708+
Add an API Gateway Websocket method to the list of allowed methods for the policy.
709+
710+
This method adds an API Gateway Websocket method Resource path) to the list of
711+
allowed methods for the policy. It optionally includes conditions for the policy statement.
712+
713+
Parameters
714+
----------
715+
resource : str
716+
The API Gateway resource path to allow.
717+
conditions : list[dict] | None, optional
718+
A list of condition dictionaries to apply to the policy statement.
719+
Default is None.
720+
721+
Notes
722+
-----
723+
For more information on AWS policy conditions, see:
724+
https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html#Condition
725+
726+
Example
727+
--------
728+
>>> policy = APIGatewayAuthorizerResponseWebSocket(...)
729+
>>> policy.allow_route("/api/users", [{"StringEquals": {"aws:RequestTag/Environment": "Production"}}])
730+
"""
731+
self._add_route(effect="Allow", resource=resource, conditions=conditions)
732+
733+
# Note: we need ignore[override] because we are removing the http_method field
734+
@override
735+
def deny_route(self, resource: str, conditions: list[dict] | None = None): # type: ignore[override]
736+
"""
737+
Add an API Gateway Websocket method to the list of allowed methods for the policy.
738+
739+
This method adds an API Gateway Websocket method Resource path) to the list of
740+
denied methods for the policy. It optionally includes conditions for the policy statement.
741+
742+
Parameters
743+
----------
744+
resource : str
745+
The API Gateway resource path to allow.
746+
conditions : list[dict] | None, optional
747+
A list of condition dictionaries to apply to the policy statement.
748+
Default is None.
749+
750+
Notes
751+
-----
752+
For more information on AWS policy conditions, see:
753+
https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html#Condition
754+
755+
Example
756+
--------
757+
>>> policy = APIGatewayAuthorizerResponseWebSocket(...)
758+
>>> policy.deny_route("/api/users", [{"StringEquals": {"aws:RequestTag/Environment": "Production"}}])
759+
"""
760+
self._add_route(effect="Deny", resource=resource, conditions=conditions)

0 commit comments

Comments
 (0)