Skip to content

AWS.IoT reference

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).

const deleteConnection = yield* AWS.IoT.DeleteConnection("sensor-*");
yield* deleteConnection({ clientId: "sensor-1", cleanSession: true });

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).

const deleteShadow = yield* AWS.IoT.DeleteThingShadow(thing);
yield* deleteShadow({ shadowName: "telemetry" });

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).

const describeEndpoint = yield* AWS.IoT.DescribeEndpoint();
const { endpointAddress } = yield* describeEndpoint({
endpointType: "iot:Data-ATS",
});

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).

const describeThing = yield* AWS.IoT.DescribeThing(thing);
const { attributes } = yield* describeThing();

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).

const getConnection = yield* AWS.IoT.GetConnection("sensor-*");
const { connected } = yield* getConnection({ clientId: "sensor-1" });

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).

const getRetained = yield* AWS.IoT.GetRetainedMessage("sensors/*");
const { payload } = yield* getRetained({ topic: "sensors/1/state" });

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).

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" });

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).

const listShadows = yield* AWS.IoT.ListNamedShadowsForThing(thing);
const { results } = yield* listShadows();

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).

const listRetained = yield* AWS.IoT.ListRetainedMessages();
const { retainedTopics } = yield* listRetained();

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).

const listSubscriptions = yield* AWS.IoT.ListSubscriptions("sensor-*");
const { subscriptions } = yield* listSubscriptions({
clientId: "sensor-1",
});

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).

const listThings = yield* AWS.IoT.ListThings();
const { things } = yield* listThings({
attributeName: "location",
attributeValue: "warehouse-a",
});

Source: src/AWS/IoT/Policy.ts

An AWS IoT policy that grants MQTT permissions (connect, publish, subscribe, receive) to certificates and other principals.

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: "*" },
],
},
});

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.

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)),
);

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).

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.

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" },
});

Source: src/AWS/IoT/ThingType.ts

An AWS IoT Thing Type — a reusable template describing a class of things.

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" },
});

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.).

const rule = yield* TopicRule("ingest", {
sql: "SELECT * FROM 'sensors/+/telemetry'",
actions: [{ lambda: { functionArn: yield* fn.functionArn } }],
});

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.

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).

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 } } }),
});