Skip to content
GitHubXDiscord

Thing

The Thing resource allows you to manage AWS IoT Things which represent physical devices or logical entities that connect to AWS IoT. This resource provides the ability to create, update, and configure IoT Things, including their attributes and names.

Create a basic IoT Thing with a specified name and an attribute payload.

import AWS from "alchemy/aws/control";
const myIoTThing = await AWS.IoT.Thing("myFirstIoTThing", {
ThingName: "MyFirstIoTDevice",
AttributePayload: {
attributes: {
manufacturer: "Acme Corp",
model: "v1.0"
}
}
});

Configure an IoT Thing with additional properties, including adopting an existing resource.

const advancedIoTThing = await AWS.IoT.Thing("advancedIoTThing", {
ThingName: "AdvancedIoTDevice",
AttributePayload: {
attributes: {
manufacturer: "Acme Corp",
model: "v2.0",
location: "Warehouse A"
}
},
adopt: true // Adopts the existing thing if it already exists
});

Create a Thing with custom attributes to support device identification and categorization.

const categorizedIoTThing = await AWS.IoT.Thing("categorizedIoTThing", {
ThingName: "TemperatureSensor",
AttributePayload: {
attributes: {
manufacturer: "SensorTech",
model: "TempPro",
location: "Building 1",
sensorType: "Temperature"
}
}
});

Demonstrate how to update an existing IoT Thing’s attributes.

const updatedIoTThing = await AWS.IoT.Thing("updatedIoTThing", {
ThingName: "TemperatureSensor",
AttributePayload: {
attributes: {
manufacturer: "SensorTech",
model: "TempPro",
location: "Building 1",
sensorType: "Temperature",
lastServiced: "2023-10-01" // New attribute added
}
},
adopt: true // Adopts the existing thing
});