AWS.IoT reference
DeleteConnection
Section titled “DeleteConnection”Source:
src/AWS/IoT/DeleteConnection.ts
Runtime binding for the IoT data-plane DeleteConnection operation (IAM
action iot:DeleteConnection).
Binding to a client id filter grants iot:DeleteConnection on matching
MQTT client ARNs (or all clients when the filter is omitted) and returns
a callable that force-disconnects a connected client, optionally cleaning
its session state. Provide the implementation with
Effect.provide(AWS.IoT.DeleteConnectionHttp).
DeleteConnection: MQTT Connections
Section titled “DeleteConnection: MQTT Connections”const deleteConnection = yield* AWS.IoT.DeleteConnection("sensor-*");
yield* deleteConnection({ clientId: "sensor-1", cleanSession: true });DeleteThingShadow
Section titled “DeleteThingShadow”Source:
src/AWS/IoT/DeleteThingShadow.ts
Runtime binding for the IoT data-plane DeleteThingShadow operation (IAM
action iot:DeleteThingShadow).
Bind it to a Thing to delete the thing’s device shadow — the thing
name is injected automatically. Provide the implementation with
Effect.provide(AWS.IoT.DeleteThingShadowHttp).
DeleteThingShadow: Device Shadows
Section titled “DeleteThingShadow: Device Shadows”const deleteShadow = yield* AWS.IoT.DeleteThingShadow(thing);
yield* deleteShadow({ shadowName: "telemetry" });DescribeEndpoint
Section titled “DescribeEndpoint”Source:
src/AWS/IoT/DescribeEndpoint.ts
Runtime binding for the DescribeEndpoint operation (IAM action
iot:DescribeEndpoint, granted on *).
Returns the account-specific IoT endpoint — pass
endpointType: "iot:Data-ATS" for the recommended ATS data endpoint that
devices and MQTT clients connect to. Provide the implementation with
Effect.provide(AWS.IoT.DescribeEndpointHttp).
DescribeEndpoint: Endpoints
Section titled “DescribeEndpoint: Endpoints”const describeEndpoint = yield* AWS.IoT.DescribeEndpoint();
const { endpointAddress } = yield* describeEndpoint({ endpointType: "iot:Data-ATS",});DescribeThing
Section titled “DescribeThing”Source:
src/AWS/IoT/DescribeThing.ts
Runtime binding for the DescribeThing operation (IAM action
iot:DescribeThing).
Bind it to a Thing to read the thing’s registry entry (attributes,
thing type, version) at runtime — the thing name is injected
automatically. Provide the implementation with
Effect.provide(AWS.IoT.DescribeThingHttp).
DescribeThing: Registry
Section titled “DescribeThing: Registry”const describeThing = yield* AWS.IoT.DescribeThing(thing);
const { attributes } = yield* describeThing();GetConnection
Section titled “GetConnection”Source:
src/AWS/IoT/GetConnection.ts
Runtime binding for the IoT data-plane GetConnection operation (IAM
action iot:GetConnection).
Binding to a client id filter grants iot:GetConnection on matching
MQTT client ARNs (or all clients when the filter is omitted) and returns
a callable that reads a client’s connection state. Provide the
implementation with Effect.provide(AWS.IoT.GetConnectionHttp).
GetConnection: MQTT Connections
Section titled “GetConnection: MQTT Connections”const getConnection = yield* AWS.IoT.GetConnection("sensor-*");
const { connected } = yield* getConnection({ clientId: "sensor-1" });GetRetainedMessage
Section titled “GetRetainedMessage”Source:
src/AWS/IoT/GetRetainedMessage.ts
Runtime binding for the IoT data-plane GetRetainedMessage operation (IAM
action iot:GetRetainedMessage).
Binding to a topic filter grants iot:GetRetainedMessage on matching
topics (or all topics when the filter is omitted) and returns a callable
that reads the retained MQTT message for a concrete topic. Provide the
implementation with Effect.provide(AWS.IoT.GetRetainedMessageHttp).
GetRetainedMessage: Retained Messages
Section titled “GetRetainedMessage: Retained Messages”const getRetained = yield* AWS.IoT.GetRetainedMessage("sensors/*");
const { payload } = yield* getRetained({ topic: "sensors/1/state" });GetThingShadow
Section titled “GetThingShadow”Source:
src/AWS/IoT/GetThingShadow.ts
Runtime binding for the IoT data-plane GetThingShadow operation (IAM
action iot:GetThingShadow).
Bind it to a Thing to read the thing’s device shadow — the thing
name is injected automatically. The response payload is a byte Stream;
decode it with Stream.decodeText + Stream.mkString. Provide the
implementation with Effect.provide(AWS.IoT.GetThingShadowHttp).
GetThingShadow: Device Shadows
Section titled “GetThingShadow: Device Shadows”Read the Classic Shadow
const getShadow = yield* AWS.IoT.GetThingShadow(thing);
const state = yield* getShadow().pipe( Effect.flatMap((result) => Stream.mkString(Stream.decodeText(result.payload!)), ),);Read a Named Shadow
const result = yield* getShadow({ shadowName: "telemetry" });ListNamedShadowsForThing
Section titled “ListNamedShadowsForThing”Source:
src/AWS/IoT/ListNamedShadowsForThing.ts
Runtime binding for the IoT data-plane ListNamedShadowsForThing
operation (IAM action iot:ListNamedShadowsForThing).
Bind it to a Thing to list the thing’s named shadows — the thing
name is injected automatically. Provide the implementation with
Effect.provide(AWS.IoT.ListNamedShadowsForThingHttp).
ListNamedShadowsForThing: Device Shadows
Section titled “ListNamedShadowsForThing: Device Shadows”const listShadows = yield* AWS.IoT.ListNamedShadowsForThing(thing);
const { results } = yield* listShadows();ListRetainedMessages
Section titled “ListRetainedMessages”Source:
src/AWS/IoT/ListRetainedMessages.ts
Runtime binding for the IoT data-plane ListRetainedMessages operation
(IAM action iot:ListRetainedMessages, granted on * — the action does
not support resource-level permissions).
Returns summaries (topic, payload size, QoS) of all retained MQTT
messages in the account; read a payload with
GetRetainedMessage. Provide the implementation with
Effect.provide(AWS.IoT.ListRetainedMessagesHttp).
ListRetainedMessages: Retained Messages
Section titled “ListRetainedMessages: Retained Messages”const listRetained = yield* AWS.IoT.ListRetainedMessages();
const { retainedTopics } = yield* listRetained();ListSubscriptions
Section titled “ListSubscriptions”Source:
src/AWS/IoT/ListSubscriptions.ts
Runtime binding for the IoT data-plane ListSubscriptions operation (IAM
action iot:ListSubscriptions).
Binding to a client id filter grants iot:ListSubscriptions on matching
MQTT client ARNs (or all clients when the filter is omitted) and returns
a callable that lists the topic filters a connected client is subscribed
to. Provide the implementation with
Effect.provide(AWS.IoT.ListSubscriptionsHttp).
ListSubscriptions: MQTT Connections
Section titled “ListSubscriptions: MQTT Connections”const listSubscriptions = yield* AWS.IoT.ListSubscriptions("sensor-*");
const { subscriptions } = yield* listSubscriptions({ clientId: "sensor-1",});ListThings
Section titled “ListThings”Source:
src/AWS/IoT/ListThings.ts
Runtime binding for the ListThings operation (IAM action
iot:ListThings, granted on * — the action does not support
resource-level permissions).
Lists things in the registry, optionally filtered by attribute or thing
type. Provide the implementation with
Effect.provide(AWS.IoT.ListThingsHttp).
ListThings: Registry
Section titled “ListThings: Registry”const listThings = yield* AWS.IoT.ListThings();
const { things } = yield* listThings({ attributeName: "location", attributeValue: "warehouse-a",});Policy
Section titled “Policy”Source:
src/AWS/IoT/Policy.ts
An AWS IoT policy that grants MQTT permissions (connect, publish, subscribe, receive) to certificates and other principals.
Policy: Creating a Policy
Section titled “Policy: Creating a Policy”const policy = yield* Policy("device-policy", { policyDocument: { Version: "2012-10-17", Statement: [ { Effect: "Allow", Action: "iot:Connect", Resource: "*" }, { Effect: "Allow", Action: ["iot:Publish", "iot:Receive"], Resource: "*" }, ], },});Publish
Section titled “Publish”Source:
src/AWS/IoT/Publish.ts
A capability that lets a Function publish MQTT messages to AWS IoT Core topics via the IoT data plane.
Binding to a topic filter grants the host iot:Publish on matching topics
(or on all topics when the filter is omitted) and returns a runtime callable
for the data-plane Publish API. Provide the PublishHttp layer on
the Function.
Publish: Publishing Messages
Section titled “Publish: Publishing Messages”export default TelemetryFunction.make( { main: import.meta.url, functionUrl: true }, Effect.gen(function* () { // grants iot:Publish on sensors/* to this function const publish = yield* AWS.IoT.Publish("sensors/*");
return { fetch: Effect.gen(function* () { yield* publish({ topic: "sensors/1/telemetry", payload: JSON.stringify({ t: 22.5 }), }); return HttpServerResponse.json({ ok: true }); }).pipe(Effect.orDie), }; }).pipe(Effect.provide(AWS.IoT.PublishHttp)),);SendDirectMessage
Section titled “SendDirectMessage”Source:
src/AWS/IoT/SendDirectMessage.ts
Runtime binding for the IoT data-plane SendDirectMessage operation (IAM
action iot:SendDirectMessage).
Binding to a client id filter grants iot:SendDirectMessage on matching
MQTT client ARNs (or all clients when the filter is omitted) and returns
a callable that delivers a message directly to a connected client without
publishing through a topic. Provide the implementation with
Effect.provide(AWS.IoT.SendDirectMessageHttp).
SendDirectMessage: MQTT Connections
Section titled “SendDirectMessage: MQTT Connections”const sendDirectMessage = yield* AWS.IoT.SendDirectMessage("sensor-*");
yield* sendDirectMessage({ clientId: "sensor-1", topic: "commands/reboot", payload: JSON.stringify({ at: "now" }),});Source:
src/AWS/IoT/Thing.ts
An AWS IoT Thing — the cloud representation of a physical device.
Thing: Creating a Thing
Section titled “Thing: Creating a Thing”Basic Thing
const thing = yield* Thing("sensor", {});Thing with Attributes
const thing = yield* Thing("sensor", { thingName: "temperature-sensor-01", attributes: { location: "warehouse-a", model: "acme-t1000" },});ThingType
Section titled “ThingType”Source:
src/AWS/IoT/ThingType.ts
An AWS IoT Thing Type — a reusable template describing a class of things.
ThingType: Creating a Thing Type
Section titled “ThingType: Creating a Thing Type”Basic Thing Type
const thingType = yield* ThingType("sensor-type", { description: "Temperature sensors", searchableAttributes: ["location", "model"],});Create a Thing of this Type
const thingType = yield* ThingType("sensor-type", { searchableAttributes: ["location"],});
const thing = yield* Thing("sensor", { thingTypeName: thingType.thingTypeName, attributes: { location: "warehouse-a" },});TopicRule
Section titled “TopicRule”Source:
src/AWS/IoT/TopicRule.ts
An AWS IoT topic rule — evaluates an SQL statement against messages published to MQTT topics and routes matching messages to one or more actions (invoke a Lambda, enqueue to SQS, republish, etc.).
TopicRule: Creating a Rule
Section titled “TopicRule: Creating a Rule”const rule = yield* TopicRule("ingest", { sql: "SELECT * FROM 'sensors/+/telemetry'", actions: [{ lambda: { functionArn: yield* fn.functionArn } }],});TopicRuleEventSource
Section titled “TopicRuleEventSource”Source:
src/AWS/IoT/TopicRuleEventSource.ts
Event source connecting an IoT topic filter to the hosting compute.
The contract is a Context service consumed via
consumeTopicMessages; the Lambda implementation layer is
AWS.Lambda.TopicRuleEventSource, which deploys an IoT TopicRule
with a Lambda action (plus the invoke permission) and streams matching
messages into the registered handler.
UpdateThingShadow
Section titled “UpdateThingShadow”Source:
src/AWS/IoT/UpdateThingShadow.ts
Runtime binding for the IoT data-plane UpdateThingShadow operation (IAM
action iot:UpdateThingShadow).
Bind it to a Thing to write the thing’s device shadow — the thing
name is injected automatically. Provide the implementation with
Effect.provide(AWS.IoT.UpdateThingShadowHttp).
UpdateThingShadow: Device Shadows
Section titled “UpdateThingShadow: Device Shadows”Set Desired State
const updateShadow = yield* AWS.IoT.UpdateThingShadow(thing);
yield* updateShadow({ payload: JSON.stringify({ state: { desired: { led: "on" } } }),});Write a Named Shadow
yield* updateShadow({ shadowName: "telemetry", payload: JSON.stringify({ state: { reported: { t: 22.5 } } }),});