Skip to content

Commit 4fd97ea

Browse files
authored
Merge branch 'develop' into docs/quick-start
2 parents 5618a99 + 24ab726 commit 4fd97ea

13 files changed

+102
-95
lines changed

.github/mergify.yml

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1+
queue_rules:
2+
- name: default
3+
conditions:
4+
# Conditions to get out of the queue (= merged)
5+
- check-success=Semantic Pull Request
6+
- "#approved-reviews-by>=1"
7+
- -title~=(WIP|wip)
8+
- -label~="do-not-merge"
9+
- "#changes-requested-reviews-by=0"
10+
111
pull_request_rules:
212
- name: automatic merge for Dependabot pull requests
313
conditions:
414
- author~=^dependabot(|-preview)\[bot\]$
515
# - check-success=build # matrix jobs aren't working in mergify
6-
- -label~="do-not-merge"
7-
- "#approved-reviews-by>=1" # until we exclude major versions in dependabot
816
actions:
9-
merge:
10-
strict: false
17+
queue:
1118
method: squash
1219
commit_message: title+body
1320

1421
- name: Automatic merge ⬇️ on approval ✔
1522
conditions:
1623
- base!=master
17-
- "#approved-reviews-by>=1"
18-
- "#changes-requested-reviews-by=0"
19-
- -title~=(WIP|wip)
2024
# - check-success=build # matrix jobs aren't working in mergify
21-
- check-success=Semantic Pull Request
22-
- body~=(?m)^\[X\] Meet tenets criteria
25+
- "#approved-reviews-by>=2"
2326
actions:
24-
merge:
25-
strict: smart
27+
queue:
2628
method: squash
27-
strict_method: merge
2829
commit_message: title+body

README.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
[![codecov.io](https://codecov.io/github/awslabs/aws-lambda-powertools-python/branch/develop/graphs/badge.svg)](https://app.codecov.io/gh/awslabs/aws-lambda-powertools-python)
55
![PythonSupport](https://img.shields.io/static/v1?label=python&message=3.6%20|%203.7|%203.8|%203.9&color=blue?style=flat-square&logo=python) ![PyPI version](https://badge.fury.io/py/aws-lambda-powertools.svg) ![PyPi monthly downloads](https://img.shields.io/pypi/dm/aws-lambda-powertools)
66

7-
A suite of Python utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more. ([AWS Lambda Powertools Java](https://github.com/awslabs/aws-lambda-powertools-java) is also available).
8-
9-
7+
A suite of Python utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more. (AWS Lambda Powertools [Java](https://github.com/awslabs/aws-lambda-powertools-java) and [Typescript](https://github.com/awslabs/aws-lambda-powertools-typescript) is also available).
108

119
**[📜Documentation](https://awslabs.github.io/aws-lambda-powertools-python/)** | **[🐍PyPi](https://pypi.org/project/aws-lambda-powertools/)** | **[Roadmap](https://github.com/awslabs/aws-lambda-powertools-roadmap/projects/1)** | **[Detailed blog post](https://aws.amazon.com/blogs/opensource/simplifying-serverless-best-practices-with-lambda-powertools/)**
1210

@@ -48,10 +46,9 @@ With [pip](https://pip.pypa.io/en/latest/index.html) installed, run: ``pip insta
4846
* Structured logging initial implementation from [aws-lambda-logging](https://gitlab.com/hadrien/aws_lambda_logging)
4947
* Powertools idea [DAZN Powertools](https://github.com/getndazn/dazn-lambda-powertools/)
5048

51-
5249
## Connect
5350

54-
* **AWS Developers Slack**: `#lambda-powertools`** - **[Invite, if you don't have an account](https://join.slack.com/t/awsdevelopers/shared_invite/zt-gu30gquv-EhwIYq3kHhhysaZ2aIX7ew)**
51+
* **AWS Developers Slack**: `#lambda-powertools` - **[Invite, if you don't have an account](https://join.slack.com/t/awsdevelopers/shared_invite/zt-yryddays-C9fkWrmguDv0h2EEDzCqvw)**
5552
* **Email**: [email protected]
5653

5754
## License

aws_lambda_powertools/event_handler/api_gateway.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def __init__(
101101
only be used during development.
102102
allow_headers: Optional[List[str]]
103103
The list of additional allowed headers. This list is added to list of
104-
built in allowed headers: `Authorization`, `Content-Type`, `X-Amz-Date`,
104+
built-in allowed headers: `Authorization`, `Content-Type`, `X-Amz-Date`,
105105
`X-Api-Key`, `X-Amz-Security-Token`.
106106
expose_headers: Optional[List[str]]
107107
A list of values to return for the Access-Control-Expose-Headers

aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ def __init__(
2828
self.api_id = api_id
2929
self.stage = stage
3030
self.http_method = http_method
31-
self.resource = resource
31+
# Remove matching "/" from `resource`.
32+
self.resource = resource.lstrip("/")
3233

3334
@property
3435
def arn(self) -> str:
35-
"""Build an arn from it's parts
36+
"""Build an arn from its parts
3637
eg: arn:aws:execute-api:us-east-1:123456789012:abcdef123/test/GET/request"""
3738
return (
3839
f"arn:{self.partition}:execute-api:{self.region}:{self.aws_account_id}:{self.api_id}/{self.stage}/"
@@ -168,7 +169,7 @@ def get_header_value(
168169
default_value: str, optional
169170
Default value if no value was found by name
170171
case_sensitive: bool
171-
Whether to use a case sensitive look up
172+
Whether to use a case-sensitive look up
172173
Returns
173174
-------
174175
str, optional
@@ -270,7 +271,7 @@ def get_header_value(
270271
default_value: str, optional
271272
Default value if no value was found by name
272273
case_sensitive: bool
273-
Whether to use a case sensitive look up
274+
Whether to use a case-sensitive look up
274275
Returns
275276
-------
276277
str, optional
@@ -440,9 +441,6 @@ def _add_route(self, effect: str, http_method: str, resource: str, conditions: O
440441
if not self._resource_pattern.match(resource):
441442
raise ValueError(f"Invalid resource path: {resource}. Path should match {self.path_regex}")
442443

443-
if resource[:1] == "/":
444-
resource = resource[1:]
445-
446444
resource_arn = APIGatewayRouteArn(
447445
self.region, self.aws_account_id, self.api_id, self.stage, http_method, resource
448446
).arn

aws_lambda_powertools/utilities/data_classes/appsync_resolver_event.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def source_ip(self) -> List[str]:
2727

2828
@property
2929
def username(self) -> str:
30-
"""The user name of the authenticated user. IAM user principal"""
30+
"""The username of the authenticated user. IAM user principal"""
3131
return self["username"]
3232

3333
@property
@@ -72,7 +72,7 @@ def source_ip(self) -> List[str]:
7272

7373
@property
7474
def username(self) -> str:
75-
"""The user name of the authenticated user."""
75+
"""The username of the authenticated user."""
7676
return self["username"]
7777

7878
@property
@@ -172,7 +172,7 @@ def arguments(self) -> Dict[str, Any]:
172172
def identity(self) -> Union[None, AppSyncIdentityIAM, AppSyncIdentityCognito]:
173173
"""An object that contains information about the caller.
174174
175-
Depending of the type of identify found:
175+
Depending on the type of identify found:
176176
177177
- API_KEY authorization - returns None
178178
- AWS_IAM authorization - returns AppSyncIdentityIAM
@@ -223,7 +223,7 @@ def get_header_value(
223223
default_value: str, optional
224224
Default value if no value was found by name
225225
case_sensitive: bool
226-
Whether to use a case sensitive look up
226+
Whether to use a case-sensitive look up
227227
Returns
228228
-------
229229
str, optional

aws_lambda_powertools/utilities/data_classes/cognito_user_pool_event.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def final_user_status(self) -> Optional[str]:
195195
@final_user_status.setter
196196
def final_user_status(self, value: str):
197197
"""During sign-in, this attribute can be set to CONFIRMED, or not set, to auto-confirm your users and
198-
allow them to sign-in with their previous passwords. This is the simplest experience for the user.
198+
allow them to sign in with their previous passwords. This is the simplest experience for the user.
199199
200200
If this attribute is set to RESET_REQUIRED, the user is required to change his or her password immediately
201201
after migration at the time of sign-in, and your client app needs to handle the PasswordResetRequiredException
@@ -333,7 +333,7 @@ class CustomMessageTriggerEvent(BaseTriggerEvent):
333333
verification code automatically to the user. Cannot be used for other attributes.
334334
- `CustomMessage_VerifyUserAttribute` This trigger sends a verification code to the user when they manually
335335
request it for a new email or phone number.
336-
- `CustomMessage_Authentication` To send MFA code during authentication.
336+
- `CustomMessage_Authentication` To send MFA codes during authentication.
337337
338338
Documentation:
339339
--------------
@@ -590,7 +590,7 @@ def user_attributes(self) -> Dict[str, str]:
590590
@property
591591
def user_not_found(self) -> Optional[bool]:
592592
"""A Boolean that is populated when PreventUserExistenceErrors is set to ENABLED for your user pool client.
593-
A value of true means that the user id (user name, email address, etc.) did not match any existing users."""
593+
A value of true means that the user id (username, email address, etc.) did not match any existing users."""
594594
return self["request"].get("userNotFound")
595595

596596
@property
@@ -601,7 +601,7 @@ def session(self) -> List[ChallengeResult]:
601601
@property
602602
def client_metadata(self) -> Optional[Dict[str, str]]:
603603
"""One or more key-value pairs that you can provide as custom input to the Lambda function that you specify
604-
for the define auth challenge trigger."""
604+
for the defined auth challenge trigger."""
605605
return self["request"].get("clientMetadata")
606606

607607

@@ -687,7 +687,7 @@ def session(self) -> List[ChallengeResult]:
687687
@property
688688
def client_metadata(self) -> Optional[Dict[str, str]]:
689689
"""One or more key-value pairs that you can provide as custom input to the Lambda function that you
690-
specify for the create auth challenge trigger."""
690+
specify for the creation auth challenge trigger."""
691691
return self["request"].get("clientMetadata")
692692

693693

@@ -699,7 +699,7 @@ def public_challenge_parameters(self) -> Dict[str, str]:
699699
@public_challenge_parameters.setter
700700
def public_challenge_parameters(self, value: Dict[str, str]):
701701
"""One or more key-value pairs for the client app to use in the challenge to be presented to the user.
702-
This parameter should contain all of the necessary information to accurately present the challenge to
702+
This parameter should contain all the necessary information to accurately present the challenge to
703703
the user."""
704704
self["response"]["publicChallengeParameters"] = value
705705

@@ -709,8 +709,8 @@ def private_challenge_parameters(self) -> Dict[str, str]:
709709

710710
@private_challenge_parameters.setter
711711
def private_challenge_parameters(self, value: Dict[str, str]):
712-
"""This parameter is only used by the Verify Auth Challenge Response Lambda trigger.
713-
This parameter should contain all of the information that is required to validate the user's
712+
"""This parameter is only used by the "Verify Auth Challenge" Response Lambda trigger.
713+
This parameter should contain all the information that is required to validate the user's
714714
response to the challenge. In other words, the publicChallengeParameters parameter contains the
715715
question that is presented to the user and privateChallengeParameters contains the valid answers
716716
for the question."""
@@ -730,7 +730,7 @@ class CreateAuthChallengeTriggerEvent(BaseTriggerEvent):
730730
"""Create Auth Challenge Lambda Trigger
731731
732732
Amazon Cognito invokes this trigger after Define Auth Challenge if a custom challenge has been
733-
specified as part of the Define Auth Challenge trigger.
733+
specified as part of the "Define Auth Challenge" trigger.
734734
It creates a custom authentication flow.
735735
736736
Notes:
@@ -775,7 +775,7 @@ def challenge_answer(self) -> Any:
775775
@property
776776
def client_metadata(self) -> Optional[Dict[str, str]]:
777777
"""One or more key-value pairs that you can provide as custom input to the Lambda function that
778-
you specify for the verify auth challenge trigger."""
778+
you specify for the "Verify Auth Challenge" trigger."""
779779
return self["request"].get("clientMetadata")
780780

781781
@property

aws_lambda_powertools/utilities/data_classes/dynamo_db_stream_event.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def aws_region(self) -> Optional[str]:
231231

232232
@property
233233
def dynamodb(self) -> Optional[StreamRecord]:
234-
"""The main body of the stream record, containing all of the DynamoDB-specific fields."""
234+
"""The main body of the stream record, containing all the DynamoDB-specific fields."""
235235
stream_record = self.get("dynamodb")
236236
return None if stream_record is None else StreamRecord(stream_record)
237237

aws_lambda_powertools/utilities/data_classes/s3_object_event.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def get_header_value(
8282
default_value: str, optional
8383
Default value if no value was found by name
8484
case_sensitive: bool
85-
Whether to use a case sensitive look up
85+
Whether to use a case-sensitive look up
8686
Returns
8787
-------
8888
str, optional
@@ -128,7 +128,7 @@ def creation_date(self) -> str:
128128
@property
129129
def mfa_authenticated(self) -> str:
130130
"""The value is true if the root user or IAM user whose credentials were used for the request also was
131-
authenticated with an MFA device; otherwise, false.."""
131+
authenticated with an MFA device; otherwise, false."""
132132
return self["mfaAuthenticated"]
133133

134134

aws_lambda_powertools/utilities/data_classes/sqs_event.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def data_type(self) -> str:
7676

7777
class SQSMessageAttributes(Dict[str, SQSMessageAttribute]):
7878
def __getitem__(self, key: str) -> Optional[SQSMessageAttribute]: # type: ignore
79-
item = super(SQSMessageAttributes, self).get(key)
79+
item = super().get(key)
8080
return None if item is None else SQSMessageAttribute(item) # type: ignore
8181

8282

aws_lambda_powertools/utilities/parameters/appconfig.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,8 @@ def _get(self, name: str, **sdk_options) -> str:
9292
----------
9393
name: str
9494
Name of the configuration
95-
environment: str
96-
Environment of the configuration
9795
sdk_options: dict, optional
98-
Dictionary of options that will be passed to the Parameter Store get_parameter API call
96+
Dictionary of options that will be passed to the client's get_configuration API call
9997
"""
10098

10199
sdk_options["Configuration"] = name
@@ -140,7 +138,7 @@ def get_app_config(
140138
max_age: int
141139
Maximum age of the cached value
142140
sdk_options: dict, optional
143-
Dictionary of options that will be passed to the Parameter Store get_parameter API call
141+
Dictionary of options that will be passed to the boto client get_configuration API call
144142
145143
Raises
146144
------
@@ -163,7 +161,7 @@ def get_app_config(
163161
164162
**Retrieves a configuration value and decodes it using a JSON decoder**
165163
166-
>>> from aws_lambda_powertools.utilities.parameters import get_parameter
164+
>>> from aws_lambda_powertools.utilities.parameters import get_app_config
167165
>>>
168166
>>> value = get_app_config("my_config", environment="my_env", application="my_env", transform='json')
169167
>>>

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A suite of utilities for AWS Lambda functions to ease adopting best practices su
1111

1212
## Tenets
1313

14-
This project separates core utilities that will be available in other runtimes vs general utilities that might not be available across all runtimes.
14+
Core utilities such as Tracing, Logging, Metrics, and Event Handler will be available across all Lambda Powertools runtimes. Additional utilities are subjective to each language ecosystem and customer demand.
1515

1616
* **AWS Lambda only**. We optimise for AWS Lambda function environments and supported runtimes only. Utilities might work with web frameworks and non-Lambda environments, though they are not officially supported.
1717
* **Eases the adoption of best practices**. The main priority of the utilities is to facilitate best practices adoption, as defined in the AWS Well-Architected Serverless Lens; all other functionality is optional.

0 commit comments

Comments
 (0)