Amazon SNS notifications delivered directly to Lambda.
%Mayfly.Events.SNS{records: [%Mayfly.Events.SNS.Record{message: %{"order" => 1}}]} =
Mayfly.Events.SNS.decode(event)message is JSON-decoded when it parses. message_attributes is flattened
to %{"name" => value}.
SNS → SQS → Lambda: the SQS record body is an SNS envelope
("Type" => "Notification"). from_envelope/1 turns such a body into a
Record:
sqs = Mayfly.Events.SQS.decode(event)
for r <- sqs.records, do: Mayfly.Events.SNS.from_envelope(r.body)
Summary
Functions
Decodes an SNS event (Records with EventSource: aws:sns).
True when an SQS body is an SNS notification envelope.
Decodes an SNS envelope (the Sns object, or an SQS body carrying one).
Types
@type t() :: %Mayfly.Events.SNS{raw: map(), records: [Mayfly.Events.SNS.Record.t()]}
Functions
Decodes an SNS event (Records with EventSource: aws:sns).
True when an SQS body is an SNS notification envelope.
@spec from_envelope(map()) :: Mayfly.Events.SNS.Record.t()
Decodes an SNS envelope (the Sns object, or an SQS body carrying one).