From 33f07b98b9bc66cb2d968bbb880b99b181fbd4a4 Mon Sep 17 00:00:00 2001 From: Ran Isenberg Date: Mon, 30 Nov 2020 11:30:46 +0200 Subject: [PATCH 1/5] feat: Add Kinesis lambda event support to Parser utility --- .../utilities/parser/envelopes/__init__.py | 10 +- .../utilities/parser/envelopes/kinesis.py | 43 +++++++ .../utilities/parser/models/__init__.py | 4 + .../utilities/parser/models/kinesis.py | 37 ++++++ tests/functional/parser/schemas.py | 5 + tests/functional/parser/test_kinesis.py | 106 ++++++++++++++++++ 6 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 aws_lambda_powertools/utilities/parser/envelopes/kinesis.py create mode 100644 aws_lambda_powertools/utilities/parser/models/kinesis.py create mode 100644 tests/functional/parser/test_kinesis.py diff --git a/aws_lambda_powertools/utilities/parser/envelopes/__init__.py b/aws_lambda_powertools/utilities/parser/envelopes/__init__.py index 4be73363b0f..4bd157a7070 100644 --- a/aws_lambda_powertools/utilities/parser/envelopes/__init__.py +++ b/aws_lambda_powertools/utilities/parser/envelopes/__init__.py @@ -1,7 +1,15 @@ from .base import BaseEnvelope from .dynamodb import DynamoDBStreamEnvelope from .event_bridge import EventBridgeEnvelope +from .kinesis import KinesisEnvelope from .sns import SnsEnvelope from .sqs import SqsEnvelope -__all__ = ["DynamoDBStreamEnvelope", "EventBridgeEnvelope", "SnsEnvelope", "SqsEnvelope", "BaseEnvelope"] +__all__ = [ + "DynamoDBStreamEnvelope", + "EventBridgeEnvelope", + "KinesisEnvelope", + "SnsEnvelope", + "SqsEnvelope", + "BaseEnvelope", +] diff --git a/aws_lambda_powertools/utilities/parser/envelopes/kinesis.py b/aws_lambda_powertools/utilities/parser/envelopes/kinesis.py new file mode 100644 index 00000000000..cd520a437be --- /dev/null +++ b/aws_lambda_powertools/utilities/parser/envelopes/kinesis.py @@ -0,0 +1,43 @@ +import logging +from typing import Any, Dict, List, Optional, Union + +from ..models import KinesisStreamModel +from ..types import Model +from .base import BaseEnvelope + +logger = logging.getLogger(__name__) + + +class KinesisEnvelope(BaseEnvelope): + """Kinesis Envelope to extract array of Records + + The record's data parameter is a base64 encoded string which is parsed into a bytes array, + though it can also be a JSON encoded string. + Regardless of its type it'll be parsed into a BaseModel object. + + Note: Records will be parsed the same way so if model is str, + all items in the list will be parsed as str and npt as JSON (and vice versa) + """ + + def parse(self, data: Optional[Union[Dict[str, Any], Any]], model: Model) -> List[Optional[Model]]: + """Parses records found with model provided + + Parameters + ---------- + data : Dict + Lambda event to be parsed + model : Model + Data model provided to parse after extracting data using envelope + + Returns + ------- + List + List of records parsed with model provided + """ + logger.debug(f"Parsing incoming data with Kinesis model {KinesisStreamModel}") + parsed_envelope: KinesisStreamModel = KinesisStreamModel.parse_obj(data) + output = [] + logger.debug(f"Parsing Kinesis records in `body` with {model}") + for record in parsed_envelope.Records: + output.append(self._parse(data=record.kinesis.data.decode("utf-8"), model=model)) + return output diff --git a/aws_lambda_powertools/utilities/parser/models/__init__.py b/aws_lambda_powertools/utilities/parser/models/__init__.py index 36ba05240b0..6c09aff364d 100644 --- a/aws_lambda_powertools/utilities/parser/models/__init__.py +++ b/aws_lambda_powertools/utilities/parser/models/__init__.py @@ -1,5 +1,6 @@ from .dynamodb import DynamoDBStreamChangedRecordModel, DynamoDBStreamModel, DynamoDBStreamRecordModel from .event_bridge import EventBridgeModel +from .kinesis import KinesisStreamModel, KinesisStreamRecord, KinesisStreamRecordPayload from .ses import SesModel, SesRecordModel from .sns import SnsModel, SnsNotificationModel, SnsRecordModel from .sqs import SqsModel, SqsRecordModel @@ -9,6 +10,9 @@ "EventBridgeModel", "DynamoDBStreamChangedRecordModel", "DynamoDBStreamRecordModel", + "KinesisStreamModel", + "KinesisStreamRecord", + "KinesisStreamRecordPayload", "SesModel", "SesRecordModel", "SnsModel", diff --git a/aws_lambda_powertools/utilities/parser/models/kinesis.py b/aws_lambda_powertools/utilities/parser/models/kinesis.py new file mode 100644 index 00000000000..11a2c86bf16 --- /dev/null +++ b/aws_lambda_powertools/utilities/parser/models/kinesis.py @@ -0,0 +1,37 @@ +import base64 +from binascii import Error as BinAsciiError +from typing import List + +from pydantic import BaseModel, validator +from pydantic.types import PositiveInt +from typing_extensions import Literal + + +class KinesisStreamRecordPayload(BaseModel): + kinesisSchemaVersion: str + partitionKey: str + sequenceNumber: PositiveInt + data: bytes # base64 encoded str is parsed into bytes + approximateArrivalTimestamp: float + + @validator("data", pre=True) + def data_base64_decode(cls, value): + try: + return base64.b64decode(value) + except (BinAsciiError, TypeError): + raise ValueError("base64 decode failed") + + +class KinesisStreamRecord(BaseModel): + eventSource: Literal["aws:kinesis"] + eventVersion: str + eventID: str + eventName: Literal["aws:kinesis:record"] + invokeIdentityArn: str + awsRegion: str + eventSourceARN: str + kinesis: KinesisStreamRecordPayload + + +class KinesisStreamModel(BaseModel): + Records: List[KinesisStreamRecord] diff --git a/tests/functional/parser/schemas.py b/tests/functional/parser/schemas.py index bfc601e3537..9f7bfa38ff3 100644 --- a/tests/functional/parser/schemas.py +++ b/tests/functional/parser/schemas.py @@ -71,3 +71,8 @@ class MyAdvancedSnsRecordModel(SnsRecordModel): class MyAdvancedSnsBusiness(SnsModel): Records: List[MyAdvancedSnsRecordModel] + + +class MyKinesisBusiness(BaseModel): + message: str + username: str diff --git a/tests/functional/parser/test_kinesis.py b/tests/functional/parser/test_kinesis.py new file mode 100644 index 00000000000..a218f1aecf0 --- /dev/null +++ b/tests/functional/parser/test_kinesis.py @@ -0,0 +1,106 @@ +from typing import Any, List + +import pytest + +from aws_lambda_powertools.utilities.parser import ValidationError, envelopes, event_parser +from aws_lambda_powertools.utilities.parser.models import KinesisStreamModel, KinesisStreamRecordPayload +from aws_lambda_powertools.utilities.typing import LambdaContext +from tests.functional.parser.schemas import MyKinesisBusiness +from tests.functional.parser.utils import load_event + + +@event_parser(model=MyKinesisBusiness, envelope=envelopes.KinesisEnvelope) +def handle_kinesis(event: List[MyKinesisBusiness], _: LambdaContext): + assert len(event) == 1 + record: KinesisStreamModel = event[0] + assert record.message == "test message" + assert record.username == "test" + + +@event_parser(model=KinesisStreamModel) +def handle_kinesis_no_envelope(event: KinesisStreamModel, _: LambdaContext): + records = event.Records + assert len(records) == 2 + record: KinesisStreamModel = records[0] + + assert record.awsRegion == "us-east-2" + assert record.eventID == "shardId-000000000006:49590338271490256608559692538361571095921575989136588898" + assert record.eventName == "aws:kinesis:record" + assert record.eventSource == "aws:kinesis" + assert record.eventSourceARN == "arn:aws:kinesis:us-east-2:123456789012:stream/lambda-stream" + assert record.eventVersion == "1.0" + assert record.invokeIdentityArn == "arn:aws:iam::123456789012:role/lambda-role" + + kinesis: KinesisStreamRecordPayload = record.kinesis + assert kinesis.approximateArrivalTimestamp == 1545084650.987 + assert kinesis.kinesisSchemaVersion == "1.0" + assert kinesis.partitionKey == "1" + assert kinesis.sequenceNumber == 49590338271490256608559692538361571095921575989136588898 + assert kinesis.data == b"Hello, this is a test." + + +def test_kinesis_trigger_event(): + event_dict = { + "Records": [ + { + "kinesis": { + "kinesisSchemaVersion": "1.0", + "partitionKey": "1", + "sequenceNumber": "49590338271490256608559692538361571095921575989136588898", + "data": "eyJtZXNzYWdlIjogInRlc3QgbWVzc2FnZSIsICJ1c2VybmFtZSI6ICJ0ZXN0In0=", + "approximateArrivalTimestamp": 1545084650.987, + }, + "eventSource": "aws:kinesis", + "eventVersion": "1.0", + "eventID": "shardId-000000000006:49590338271490256608559692538361571095921575989136588898", + "eventName": "aws:kinesis:record", + "invokeIdentityArn": "arn:aws:iam::123456789012:role/lambda-role", + "awsRegion": "us-east-2", + "eventSourceARN": "arn:aws:kinesis:us-east-2:123456789012:stream/lambda-stream", + } + ] + } + + handle_kinesis(event_dict, LambdaContext()) + + +def test_kinesis_trigger_bad_base64_event(): + event_dict = { + "Records": [ + { + "kinesis": { + "kinesisSchemaVersion": "1.0", + "partitionKey": "1", + "sequenceNumber": "49590338271490256608559692538361571095921575989136588898", + "data": "bad", + "approximateArrivalTimestamp": 1545084650.987, + }, + "eventSource": "aws:kinesis", + "eventVersion": "1.0", + "eventID": "shardId-000000000006:49590338271490256608559692538361571095921575989136588898", + "eventName": "aws:kinesis:record", + "invokeIdentityArn": "arn:aws:iam::123456789012:role/lambda-role", + "awsRegion": "us-east-2", + "eventSourceARN": "arn:aws:kinesis:us-east-2:123456789012:stream/lambda-stream", + } + ] + } + with pytest.raises(ValidationError): + handle_kinesis_no_envelope(event_dict, LambdaContext()) + + +def test_kinesis_trigger_event_no_envelope(): + event_dict = load_event("kinesisStreamEvent.json") + handle_kinesis_no_envelope(event_dict, LambdaContext()) + + +def test_validate_event_does_not_conform_with_model_no_envelope(): + event_dict: Any = {"hello": "s"} + with pytest.raises(ValidationError): + handle_kinesis_no_envelope(event_dict, LambdaContext()) + + +def test_validate_event_does_not_conform_with_model(): + event_dict: Any = {"hello": "s"} + with pytest.raises(ValidationError): + handle_kinesis(event_dict, LambdaContext()) From 4716aa3062cf969e7fdd5c75e6ddcd6a7f3248f1 Mon Sep 17 00:00:00 2001 From: Ran Isenberg <60175085+risenberg-cyberark@users.noreply.github.com> Date: Tue, 1 Dec 2020 10:48:11 +0200 Subject: [PATCH 2/5] feat: Add Kinesis lambda event support to Parser utility --- .../utilities/parser/envelopes/__init__.py | 4 ++-- .../utilities/parser/envelopes/kinesis.py | 4 ++-- aws_lambda_powertools/utilities/parser/models/__init__.py | 4 ++-- aws_lambda_powertools/utilities/parser/models/kinesis.py | 8 ++++++-- tests/functional/parser/test_kinesis.py | 6 +++--- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/aws_lambda_powertools/utilities/parser/envelopes/__init__.py b/aws_lambda_powertools/utilities/parser/envelopes/__init__.py index 4bd157a7070..c963342ffd5 100644 --- a/aws_lambda_powertools/utilities/parser/envelopes/__init__.py +++ b/aws_lambda_powertools/utilities/parser/envelopes/__init__.py @@ -1,14 +1,14 @@ from .base import BaseEnvelope from .dynamodb import DynamoDBStreamEnvelope from .event_bridge import EventBridgeEnvelope -from .kinesis import KinesisEnvelope +from .kinesis import KinesisDataStreamEnvelope from .sns import SnsEnvelope from .sqs import SqsEnvelope __all__ = [ "DynamoDBStreamEnvelope", "EventBridgeEnvelope", - "KinesisEnvelope", + "KinesisDataStreamEnvelope", "SnsEnvelope", "SqsEnvelope", "BaseEnvelope", diff --git a/aws_lambda_powertools/utilities/parser/envelopes/kinesis.py b/aws_lambda_powertools/utilities/parser/envelopes/kinesis.py index cd520a437be..360126cf03c 100644 --- a/aws_lambda_powertools/utilities/parser/envelopes/kinesis.py +++ b/aws_lambda_powertools/utilities/parser/envelopes/kinesis.py @@ -8,8 +8,8 @@ logger = logging.getLogger(__name__) -class KinesisEnvelope(BaseEnvelope): - """Kinesis Envelope to extract array of Records +class KinesisDataStreamEnvelope(BaseEnvelope): + """Kinesis Data Stream Envelope to extract array of Records The record's data parameter is a base64 encoded string which is parsed into a bytes array, though it can also be a JSON encoded string. diff --git a/aws_lambda_powertools/utilities/parser/models/__init__.py b/aws_lambda_powertools/utilities/parser/models/__init__.py index 6c09aff364d..ee71f194bf0 100644 --- a/aws_lambda_powertools/utilities/parser/models/__init__.py +++ b/aws_lambda_powertools/utilities/parser/models/__init__.py @@ -1,6 +1,6 @@ from .dynamodb import DynamoDBStreamChangedRecordModel, DynamoDBStreamModel, DynamoDBStreamRecordModel from .event_bridge import EventBridgeModel -from .kinesis import KinesisStreamModel, KinesisStreamRecord, KinesisStreamRecordPayload +from .kinesis import KinesisDataStreamRecordPayload, KinesisStreamModel, KinesisStreamRecord from .ses import SesModel, SesRecordModel from .sns import SnsModel, SnsNotificationModel, SnsRecordModel from .sqs import SqsModel, SqsRecordModel @@ -12,7 +12,7 @@ "DynamoDBStreamRecordModel", "KinesisStreamModel", "KinesisStreamRecord", - "KinesisStreamRecordPayload", + "KinesisDataStreamRecordPayload", "SesModel", "SesRecordModel", "SnsModel", diff --git a/aws_lambda_powertools/utilities/parser/models/kinesis.py b/aws_lambda_powertools/utilities/parser/models/kinesis.py index 11a2c86bf16..fa11129431f 100644 --- a/aws_lambda_powertools/utilities/parser/models/kinesis.py +++ b/aws_lambda_powertools/utilities/parser/models/kinesis.py @@ -1,4 +1,5 @@ import base64 +import logging from binascii import Error as BinAsciiError from typing import List @@ -6,8 +7,10 @@ from pydantic.types import PositiveInt from typing_extensions import Literal +logger = logging.getLogger(__name__) -class KinesisStreamRecordPayload(BaseModel): + +class KinesisDataStreamRecordPayload(BaseModel): kinesisSchemaVersion: str partitionKey: str sequenceNumber: PositiveInt @@ -17,6 +20,7 @@ class KinesisStreamRecordPayload(BaseModel): @validator("data", pre=True) def data_base64_decode(cls, value): try: + logger.debug("Decoding base64 Kinesis data record before parsing") return base64.b64decode(value) except (BinAsciiError, TypeError): raise ValueError("base64 decode failed") @@ -30,7 +34,7 @@ class KinesisStreamRecord(BaseModel): invokeIdentityArn: str awsRegion: str eventSourceARN: str - kinesis: KinesisStreamRecordPayload + kinesis: KinesisDataStreamRecordPayload class KinesisStreamModel(BaseModel): diff --git a/tests/functional/parser/test_kinesis.py b/tests/functional/parser/test_kinesis.py index a218f1aecf0..83a8d4ea290 100644 --- a/tests/functional/parser/test_kinesis.py +++ b/tests/functional/parser/test_kinesis.py @@ -3,13 +3,13 @@ import pytest from aws_lambda_powertools.utilities.parser import ValidationError, envelopes, event_parser -from aws_lambda_powertools.utilities.parser.models import KinesisStreamModel, KinesisStreamRecordPayload +from aws_lambda_powertools.utilities.parser.models import KinesisDataStreamRecordPayload, KinesisStreamModel from aws_lambda_powertools.utilities.typing import LambdaContext from tests.functional.parser.schemas import MyKinesisBusiness from tests.functional.parser.utils import load_event -@event_parser(model=MyKinesisBusiness, envelope=envelopes.KinesisEnvelope) +@event_parser(model=MyKinesisBusiness, envelope=envelopes.KinesisDataStreamEnvelope) def handle_kinesis(event: List[MyKinesisBusiness], _: LambdaContext): assert len(event) == 1 record: KinesisStreamModel = event[0] @@ -31,7 +31,7 @@ def handle_kinesis_no_envelope(event: KinesisStreamModel, _: LambdaContext): assert record.eventVersion == "1.0" assert record.invokeIdentityArn == "arn:aws:iam::123456789012:role/lambda-role" - kinesis: KinesisStreamRecordPayload = record.kinesis + kinesis: KinesisDataStreamRecordPayload = record.kinesis assert kinesis.approximateArrivalTimestamp == 1545084650.987 assert kinesis.kinesisSchemaVersion == "1.0" assert kinesis.partitionKey == "1" From 9b5581703c7a17f355766df4751b9b534cf4785e Mon Sep 17 00:00:00 2001 From: Ran Isenberg Date: Tue, 1 Dec 2020 16:11:06 +0200 Subject: [PATCH 3/5] cr fixes --- .../utilities/parser/envelopes/kinesis.py | 6 +++--- .../utilities/parser/models/__init__.py | 6 +++--- .../utilities/parser/models/kinesis.py | 6 +++--- tests/functional/parser/test_kinesis.py | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/aws_lambda_powertools/utilities/parser/envelopes/kinesis.py b/aws_lambda_powertools/utilities/parser/envelopes/kinesis.py index 360126cf03c..97ad7bffec7 100644 --- a/aws_lambda_powertools/utilities/parser/envelopes/kinesis.py +++ b/aws_lambda_powertools/utilities/parser/envelopes/kinesis.py @@ -1,7 +1,7 @@ import logging from typing import Any, Dict, List, Optional, Union -from ..models import KinesisStreamModel +from ..models import KinesisDataStreamModel from ..types import Model from .base import BaseEnvelope @@ -34,8 +34,8 @@ def parse(self, data: Optional[Union[Dict[str, Any], Any]], model: Model) -> Lis List List of records parsed with model provided """ - logger.debug(f"Parsing incoming data with Kinesis model {KinesisStreamModel}") - parsed_envelope: KinesisStreamModel = KinesisStreamModel.parse_obj(data) + logger.debug(f"Parsing incoming data with Kinesis model {KinesisDataStreamModel}") + parsed_envelope: KinesisDataStreamModel = KinesisDataStreamModel.parse_obj(data) output = [] logger.debug(f"Parsing Kinesis records in `body` with {model}") for record in parsed_envelope.Records: diff --git a/aws_lambda_powertools/utilities/parser/models/__init__.py b/aws_lambda_powertools/utilities/parser/models/__init__.py index ee71f194bf0..00a2d375e26 100644 --- a/aws_lambda_powertools/utilities/parser/models/__init__.py +++ b/aws_lambda_powertools/utilities/parser/models/__init__.py @@ -1,6 +1,6 @@ from .dynamodb import DynamoDBStreamChangedRecordModel, DynamoDBStreamModel, DynamoDBStreamRecordModel from .event_bridge import EventBridgeModel -from .kinesis import KinesisDataStreamRecordPayload, KinesisStreamModel, KinesisStreamRecord +from .kinesis import KinesisDataStreamModel, KinesisDataStreamRecord, KinesisDataStreamRecordPayload from .ses import SesModel, SesRecordModel from .sns import SnsModel, SnsNotificationModel, SnsRecordModel from .sqs import SqsModel, SqsRecordModel @@ -10,8 +10,8 @@ "EventBridgeModel", "DynamoDBStreamChangedRecordModel", "DynamoDBStreamRecordModel", - "KinesisStreamModel", - "KinesisStreamRecord", + "KinesisDataStreamModel", + "KinesisDataStreamRecord", "KinesisDataStreamRecordPayload", "SesModel", "SesRecordModel", diff --git a/aws_lambda_powertools/utilities/parser/models/kinesis.py b/aws_lambda_powertools/utilities/parser/models/kinesis.py index fa11129431f..d2852e9f4a8 100644 --- a/aws_lambda_powertools/utilities/parser/models/kinesis.py +++ b/aws_lambda_powertools/utilities/parser/models/kinesis.py @@ -26,7 +26,7 @@ def data_base64_decode(cls, value): raise ValueError("base64 decode failed") -class KinesisStreamRecord(BaseModel): +class KinesisDataStreamRecord(BaseModel): eventSource: Literal["aws:kinesis"] eventVersion: str eventID: str @@ -37,5 +37,5 @@ class KinesisStreamRecord(BaseModel): kinesis: KinesisDataStreamRecordPayload -class KinesisStreamModel(BaseModel): - Records: List[KinesisStreamRecord] +class KinesisDataStreamModel(BaseModel): + Records: List[KinesisDataStreamRecord] diff --git a/tests/functional/parser/test_kinesis.py b/tests/functional/parser/test_kinesis.py index 83a8d4ea290..5a7a94e0dac 100644 --- a/tests/functional/parser/test_kinesis.py +++ b/tests/functional/parser/test_kinesis.py @@ -3,7 +3,7 @@ import pytest from aws_lambda_powertools.utilities.parser import ValidationError, envelopes, event_parser -from aws_lambda_powertools.utilities.parser.models import KinesisDataStreamRecordPayload, KinesisStreamModel +from aws_lambda_powertools.utilities.parser.models import KinesisDataStreamModel, KinesisDataStreamRecordPayload from aws_lambda_powertools.utilities.typing import LambdaContext from tests.functional.parser.schemas import MyKinesisBusiness from tests.functional.parser.utils import load_event @@ -12,16 +12,16 @@ @event_parser(model=MyKinesisBusiness, envelope=envelopes.KinesisDataStreamEnvelope) def handle_kinesis(event: List[MyKinesisBusiness], _: LambdaContext): assert len(event) == 1 - record: KinesisStreamModel = event[0] + record: KinesisDataStreamModel = event[0] assert record.message == "test message" assert record.username == "test" -@event_parser(model=KinesisStreamModel) -def handle_kinesis_no_envelope(event: KinesisStreamModel, _: LambdaContext): +@event_parser(model=KinesisDataStreamModel) +def handle_kinesis_no_envelope(event: KinesisDataStreamModel, _: LambdaContext): records = event.Records assert len(records) == 2 - record: KinesisStreamModel = records[0] + record: KinesisDataStreamModel = records[0] assert record.awsRegion == "us-east-2" assert record.eventID == "shardId-000000000006:49590338271490256608559692538361571095921575989136588898" From 3809763643ef9d0895214b0b79ab096a472091ad Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Fri, 4 Dec 2020 14:29:08 +0100 Subject: [PATCH 4/5] docs: add Kinesis Streams as a supported model & envelope --- docs/content/utilities/parser.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/content/utilities/parser.mdx b/docs/content/utilities/parser.mdx index b620f0eb18f..9b7457ef21a 100644 --- a/docs/content/utilities/parser.mdx +++ b/docs/content/utilities/parser.mdx @@ -159,6 +159,7 @@ Model name | Description **AlbModel** | Lambda Event Source payload for Amazon Application Load Balancer **CloudwatchLogsModel** | Lambda Event Source payload for Amazon CloudWatch Logs **S3Model** | Lambda Event Source payload for Amazon S3 +**KinesisDataStreamModel** | Lambda Event Source payload for Amazon Kinesis Data Streams You can extend them to include your own models, and yet have all other known fields parsed along the way. @@ -296,6 +297,7 @@ Envelope name | Behaviour | Return **EventBridgeEnvelope** | 1. Parses data using `EventBridgeModel`.
2. Parses `detail` key using your model and returns it. | `Model` **SqsEnvelope** | 1. Parses data using `SqsModel`.
2. Parses records in `body` key using your model and return them in a list. | `List[Model]` **CloudWatchLogsEnvelope** | 1. Parses data using `CloudwatchLogsModel` which will base64 decode and decompress it.
2. Parses records in `message` key using your model and return them in a list. | `List[Model]` +**KinesisDataStreamEnvelope** | 1. Parses data using `KinesisDataStreamModel` which will base64 decode it.
2. Parses records in in `Records` key using your model and returns them in a list. | `List[Model]` ### Bringing your own envelope From 43e175d1c17f434eb1d9dbc5b1627075c6972100 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Fri, 4 Dec 2020 14:35:30 +0100 Subject: [PATCH 5/5] fix: s3 model import --- aws_lambda_powertools/utilities/parser/models/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/aws_lambda_powertools/utilities/parser/models/__init__.py b/aws_lambda_powertools/utilities/parser/models/__init__.py index 9d1247ec62a..45230b8c79e 100644 --- a/aws_lambda_powertools/utilities/parser/models/__init__.py +++ b/aws_lambda_powertools/utilities/parser/models/__init__.py @@ -3,6 +3,7 @@ from .dynamodb import DynamoDBStreamChangedRecordModel, DynamoDBStreamModel, DynamoDBStreamRecordModel from .event_bridge import EventBridgeModel from .kinesis import KinesisDataStreamModel, KinesisDataStreamRecord, KinesisDataStreamRecordPayload +from .s3 import S3Model, S3RecordModel from .ses import SesModel, SesRecordModel from .sns import SnsModel, SnsNotificationModel, SnsRecordModel from .sqs import SqsModel, SqsRecordModel