Skip to content

Commit 61aa6bc

Browse files
authored
Merge branch 'develop' into v2
2 parents ec4204f + ac48766 commit 61aa6bc

File tree

20 files changed

+432
-47
lines changed

20 files changed

+432
-47
lines changed
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: I Made This (showcase your work)
2+
description: Share what you did with Powertools 💞💞. Blog post, workshops, presentation, sample apps, etc.
3+
title: "[I Made This]: <TITLE>"
4+
labels: ["community-content"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: Thank you for helping spread the word out on Powertools, truly!
9+
- type: input
10+
id: content
11+
attributes:
12+
label: Link to your material
13+
description: |
14+
Please share the original link to your material.
15+
16+
*Note: Short links will be expanded when added to Powertools documentation*
17+
validations:
18+
required: true
19+
- type: textarea
20+
id: description
21+
attributes:
22+
label: Description
23+
description: Describe in one paragraph what's in it for them (readers)
24+
validations:
25+
required: true
26+
- type: input
27+
id: author
28+
attributes:
29+
label: Preferred contact
30+
description: What's your preferred contact? We'll list it next to this content
31+
validations:
32+
required: true
33+
- type: input
34+
id: author-social
35+
attributes:
36+
label: (Optional) Social Network
37+
description: If different from preferred contact, what's your preferred contact for social interactions?
38+
validations:
39+
required: false
40+
- type: textarea
41+
id: notes
42+
attributes:
43+
label: (Optional) Additional notes
44+
description: |
45+
Any notes you might want to share with us related to this material.
46+
47+
*Note: These notes are explicitly to Powertools maintainers. It will not be added to the community resources page.*
48+
validations:
49+
required: false
50+
- type: checkboxes
51+
id: acknowledgment
52+
attributes:
53+
label: Acknowledgment
54+
options:
55+
- label: I understand this content may be removed from Powertools documentation if it doesn't conform with the [Code of Conduct](https://aws.github.io/code-of-conduct)
56+
required: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Support Lambda Powertools (become a reference)
2+
description: Add your organization's name or logo to the Lambda Powertools documentation
3+
title: "[Support Lambda Powertools]: <your organization name>"
4+
labels: ["customer-reference"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thank you for becoming a reference customer. Your support means a lot to us. It also helps new customers to know who's using it.
10+
11+
If you would like us to also display your organization's logo, please share a link in the `Company logo` field.
12+
- type: input
13+
id: organization
14+
attributes:
15+
label: Organization Name
16+
description: Please share the name of your organization
17+
placeholder: ACME
18+
validations:
19+
required: true
20+
- type: input
21+
id: name
22+
attributes:
23+
label: Your Name
24+
description: Please share your name
25+
validations:
26+
required: true
27+
- type: input
28+
id: job
29+
attributes:
30+
label: Your current position
31+
description: Please share your current position at your company
32+
validations:
33+
required: true
34+
- type: input
35+
id: logo
36+
attributes:
37+
label: (Optional) Company logo
38+
description: Company logo you want us to display. You also allow us to resize for optimal placement in the documentation.
39+
validations:
40+
required: false
41+
- type: textarea
42+
id: use_case
43+
attributes:
44+
label: (Optional) Use case
45+
description: How are you using Lambda Powertools today? *features, etc.*
46+
validations:
47+
required: false
48+
- type: checkboxes
49+
id: other_languages
50+
attributes:
51+
label: Also using other Lambda Powertools languages?
52+
options:
53+
- label: Java
54+
required: false
55+
- label: TypeScript
56+
required: false
57+
- label: .NET
58+
required: false
59+
- type: markdown
60+
attributes:
61+
value: |
62+
*By raising a Support Lambda Powertools issue, you are granting AWS permission to use your company's name (and/or logo) for the limited purpose described here. You are also confirming that you have authority to grant such permission.*
63+
64+
*You can opt-out at any time by commenting or reopening this issue.*

.github/workflows/release-drafter.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ jobs:
1010
update_release_draft:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: release-drafter/release-drafter@df69d584deac33d8569990cb6413f82447181076 # v5.20.1
13+
- uses: release-drafter/release-drafter@6df64e4ba4842c203c604c1f45246c5863410adb # v5.20.1
1414
env:
1515
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

+28-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,35 @@
44
<a name="unreleased"></a>
55
# Unreleased
66

7+
## Features
8+
9+
* **data_classes:** add KinesisFirehoseEvent ([#1540](https://github.com/awslabs/aws-lambda-powertools-python/issues/1540))
10+
11+
## Maintenance
12+
13+
* **layer:** bump to 1.31.1 (v39)
14+
15+
16+
<a name="v1.31.1"></a>
17+
## [v1.31.1] - 2022-10-14
18+
## Bug Fixes
19+
20+
* **parser:** loose validation on SNS fields to support FIFO ([#1606](https://github.com/awslabs/aws-lambda-powertools-python/issues/1606))
21+
22+
## Documentation
23+
24+
* **governance:** allow community to suggest feature content ([#1593](https://github.com/awslabs/aws-lambda-powertools-python/issues/1593))
25+
* **governance:** new form to allow customers self-nominate as public reference ([#1589](https://github.com/awslabs/aws-lambda-powertools-python/issues/1589))
26+
* **homepage:** include .NET powertools
27+
* **idempotency:** "persisntence" typo ([#1596](https://github.com/awslabs/aws-lambda-powertools-python/issues/1596))
28+
* **logger:** fix typo. ([#1587](https://github.com/awslabs/aws-lambda-powertools-python/issues/1587))
29+
730
## Maintenance
831

32+
* add dummy v2 sar deploy job
933
* bump layer version to 38
34+
* **deps-dev:** bump mypy-boto3-ssm from 1.24.81 to 1.24.90 ([#1594](https://github.com/awslabs/aws-lambda-powertools-python/issues/1594))
35+
* **deps-dev:** bump flake8-builtins from 1.5.3 to 2.0.0 ([#1582](https://github.com/awslabs/aws-lambda-powertools-python/issues/1582))
1036

1137

1238
<a name="v1.31.0"></a>
@@ -2408,7 +2434,8 @@
24082434
* Merge pull request [#5](https://github.com/awslabs/aws-lambda-powertools-python/issues/5) from jfuss/feat/python38
24092435

24102436

2411-
[Unreleased]: https://github.com/awslabs/aws-lambda-powertools-python/compare/v1.31.0...HEAD
2437+
[Unreleased]: https://github.com/awslabs/aws-lambda-powertools-python/compare/v1.31.1...HEAD
2438+
[v1.31.1]: https://github.com/awslabs/aws-lambda-powertools-python/compare/v1.31.0...v1.31.1
24122439
[v1.31.0]: https://github.com/awslabs/aws-lambda-powertools-python/compare/v1.30.0...v1.31.0
24132440
[v1.30.0]: https://github.com/awslabs/aws-lambda-powertools-python/compare/v1.29.2...v1.30.0
24142441
[v1.29.2]: https://github.com/awslabs/aws-lambda-powertools-python/compare/v1.29.1...v1.29.2

MAINTAINERS.md

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ These are the most common labels used by maintainers to triage issues, pull requ
102102
| github-actions | Changes in GitHub workflows | PR automation |
103103
| github-templates | Changes in GitHub issue/PR templates | PR automation |
104104
| internal | Changes in governance, tech debt and chores (linting setup, baseline, etc.) | PR automation |
105+
| customer-reference | Authorization to use company name in our documentation | Public Relations |
106+
| community-content | Suggested content to feature in our documentation | Public Relations |
105107

106108
## Maintainer Responsibilities
107109

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
[![Build](https://github.com/awslabs/aws-lambda-powertools-python/actions/workflows/python_build.yml/badge.svg)](https://github.com/awslabs/aws-lambda-powertools-python/actions/workflows/python_build.yml)
55
[![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)
6-
![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) ![Lambda Layer](https://api.globadge.com/v1/badgen/aws/lambda/layer/latest-version/eu-central-1/017000801446/AWSLambdaPowertoolsPython)
7-
[![Join our Discord](https://dcbadge.vercel.app/api/server/B8zZKbbyET)](https://discord.gg/B8zZKbbyET)
6+
![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) [![Join our Discord](https://dcbadge.vercel.app/api/server/B8zZKbbyET)](https://discord.gg/B8zZKbbyET)
87

9-
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 for [Java](https://github.com/awslabs/aws-lambda-powertools-java), [Typescript](https://github.com/awslabs/aws-lambda-powertools-typescript), and [.NET](https://awslabs.github.io/aws-lambda-powertools-dotnet/){target="_blank"} are also available).
8+
A suite of Python utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more.
9+
10+
> Also available in [Java](https://github.com/awslabs/aws-lambda-powertools-java), [Typescript](https://github.com/awslabs/aws-lambda-powertools-typescript), and [.NET](https://awslabs.github.io/aws-lambda-powertools-dotnet/).
1011
1112
**[📜Documentation](https://awslabs.github.io/aws-lambda-powertools-python/)** | **[🐍PyPi](https://pypi.org/project/aws-lambda-powertools/)** | **[Roadmap](https://awslabs.github.io/aws-lambda-powertools-python/latest/roadmap/)** | **[Detailed blog post](https://aws.amazon.com/blogs/opensource/simplifying-serverless-best-practices-with-lambda-powertools/)**
1213

aws_lambda_powertools/utilities/data_classes/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from .event_bridge_event import EventBridgeEvent
1414
from .event_source import event_source
1515
from .kafka_event import KafkaEvent
16+
from .kinesis_firehose_event import KinesisFirehoseEvent
1617
from .kinesis_stream_event import KinesisStreamEvent
1718
from .lambda_function_url_event import LambdaFunctionUrlEvent
1819
from .s3_event import S3Event
@@ -32,6 +33,7 @@
3233
"DynamoDBStreamEvent",
3334
"EventBridgeEvent",
3435
"KafkaEvent",
36+
"KinesisFirehoseEvent",
3537
"KinesisStreamEvent",
3638
"LambdaFunctionUrlEvent",
3739
"S3Event",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import base64
2+
import json
3+
from typing import Iterator, Optional
4+
5+
from aws_lambda_powertools.utilities.data_classes.common import DictWrapper
6+
7+
8+
class KinesisFirehoseRecordMetadata(DictWrapper):
9+
@property
10+
def _metadata(self) -> dict:
11+
"""Optional: metadata associated with this record; present only when Kinesis Stream is source"""
12+
return self["kinesisRecordMetadata"] # could raise KeyError
13+
14+
@property
15+
def shard_id(self) -> str:
16+
"""Kinesis stream shard ID; present only when Kinesis Stream is source"""
17+
return self._metadata["shardId"]
18+
19+
@property
20+
def partition_key(self) -> str:
21+
"""Kinesis stream partition key; present only when Kinesis Stream is source"""
22+
return self._metadata["partitionKey"]
23+
24+
@property
25+
def approximate_arrival_timestamp(self) -> int:
26+
"""Kinesis stream approximate arrival ISO timestamp; present only when Kinesis Stream is source"""
27+
return self._metadata["approximateArrivalTimestamp"]
28+
29+
@property
30+
def sequence_number(self) -> str:
31+
"""Kinesis stream sequence number; present only when Kinesis Stream is source"""
32+
return self._metadata["sequenceNumber"]
33+
34+
@property
35+
def subsequence_number(self) -> str:
36+
"""Kinesis stream sub-sequence number; present only when Kinesis Stream is source
37+
38+
Note: this will only be present for Kinesis streams using record aggregation
39+
"""
40+
return self._metadata["subsequenceNumber"]
41+
42+
43+
class KinesisFirehoseRecord(DictWrapper):
44+
@property
45+
def approximate_arrival_timestamp(self) -> int:
46+
"""The approximate time that the record was inserted into the delivery stream"""
47+
return self["approximateArrivalTimestamp"]
48+
49+
@property
50+
def record_id(self) -> str:
51+
"""Record ID; uniquely identifies this record within the current batch"""
52+
return self["recordId"]
53+
54+
@property
55+
def data(self) -> str:
56+
"""The data blob, base64-encoded"""
57+
return self["data"]
58+
59+
@property
60+
def metadata(self) -> Optional[KinesisFirehoseRecordMetadata]:
61+
"""Optional: metadata associated with this record; present only when Kinesis Stream is source"""
62+
return KinesisFirehoseRecordMetadata(self._data) if self.get("kinesisRecordMetadata") else None
63+
64+
@property
65+
def data_as_bytes(self) -> bytes:
66+
"""Decoded base64-encoded data as bytes"""
67+
return base64.b64decode(self.data)
68+
69+
@property
70+
def data_as_text(self) -> str:
71+
"""Decoded base64-encoded data as text"""
72+
return self.data_as_bytes.decode("utf-8")
73+
74+
@property
75+
def data_as_json(self) -> dict:
76+
"""Decoded base64-encoded data loaded to json"""
77+
if self._json_data is None:
78+
self._json_data = json.loads(self.data_as_text)
79+
return self._json_data
80+
81+
82+
class KinesisFirehoseEvent(DictWrapper):
83+
"""Kinesis Data Firehose event
84+
85+
Documentation:
86+
--------------
87+
- https://docs.aws.amazon.com/lambda/latest/dg/services-kinesisfirehose.html
88+
"""
89+
90+
@property
91+
def invocation_id(self) -> str:
92+
"""Unique ID for for Lambda invocation"""
93+
return self["invocationId"]
94+
95+
@property
96+
def delivery_stream_arn(self) -> str:
97+
"""ARN of the Firehose Data Firehose Delivery Stream"""
98+
return self["deliveryStreamArn"]
99+
100+
@property
101+
def source_kinesis_stream_arn(self) -> Optional[str]:
102+
"""ARN of the Kinesis Stream; present only when Kinesis Stream is source"""
103+
return self.get("sourceKinesisStreamArn")
104+
105+
@property
106+
def region(self) -> str:
107+
"""AWS region where the event originated eg: us-east-1"""
108+
return self["region"]
109+
110+
@property
111+
def records(self) -> Iterator[KinesisFirehoseRecord]:
112+
for record in self["records"]:
113+
yield KinesisFirehoseRecord(record)

aws_lambda_powertools/utilities/parser/models/sns.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ class SnsNotificationModel(BaseModel):
2222
MessageAttributes: Optional[Dict[str, SnsMsgAttributeModel]]
2323
Message: Union[str, TypingType[BaseModel]]
2424
MessageId: str
25-
SigningCertUrl: HttpUrl
26-
Signature: str
25+
SigningCertUrl: Optional[HttpUrl] # NOTE: FIFO opt-in removes attribute
26+
Signature: Optional[str] # NOTE: FIFO opt-in removes attribute
2727
Timestamp: datetime
28-
SignatureVersion: str
28+
SignatureVersion: Optional[str] # NOTE: FIFO opt-in removes attribute
2929

3030
@root_validator(pre=True, allow_reuse=True)
3131
def check_sqs_protocol(cls, values):

docs/core/logger.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ By default all registered loggers will be modified. You can change this behavior
619619

620620
### How can I add standard library logging attributes to a log record?
621621

622-
The Python standard library log records contains a [large set of atttributes](https://docs.python.org/3/library/logging.html#logrecord-attributes){target="_blank"}, however only a few are included in Powertools Logger log record by default.
622+
The Python standard library log records contains a [large set of attributes](https://docs.python.org/3/library/logging.html#logrecord-attributes){target="_blank"}, however only a few are included in Powertools Logger log record by default.
623623

624624
You can include any of these logging attributes as key value arguments (`kwargs`) when instantiating `Logger` or `LambdaPowertoolsFormatter`.
625625

0 commit comments

Comments
 (0)