DestinationEventSource
Source:
src/AWS/IoTWireless/DestinationEventSource.ts
Event source connecting an IoT Wireless Destination to the
hosting compute — every uplink a wireless device sends through the
destination invokes the handler.
The destination must use expressionType: "RuleName". At deploy time the
Lambda implementation (Lambda.WirelessDestinationEventSource) creates
the IoT topic rule the destination’s expression names, with a Lambda
action targeting the current function, and grants iot.amazonaws.com
permission to invoke it; at runtime it dispatches uplink invocations to
the handler.
Use the consumeUplinks helper rather than the service directly,
and provide Lambda.WirelessDestinationEventSource on the hosting
function.
Consuming Uplinks
Section titled “Consuming Uplinks”export default IngestFunction.make( { main: import.meta.url }, Effect.gen(function* () { const destination = yield* IoTWireless.Destination("Uplinks", { expressionType: "RuleName", expression: "sensor_uplinks", roleArn: deliveryRole.roleArn, });
// deploy: creates the `sensor_uplinks` IoT rule targeting this Lambda // runtime: handles every uplink routed through the destination yield* IoTWireless.consumeUplinks(destination, (uplinks) => uplinks.pipe( Stream.runForEach((uplink) => Effect.log(uplink.WirelessDeviceId, uplink.PayloadData), ), Effect.orDie, ), );
return {}; }).pipe(Effect.provide(Lambda.WirelessDestinationEventSource)),);