Skip to content
GitHubXDiscordRSS

ThingGroup

Learn how to create, update, and manage AWS IoT ThingGroups using Alchemy Cloud Control.

The ThingGroup resource allows you to manage AWS IoT ThingGroups which are collections of AWS IoT Things. ThingGroups help you organize and manage your IoT devices easily.

Create a basic ThingGroup with a name and optional parent group.

import AWS from "alchemy/aws/control";
const basicThingGroup = await AWS.IoT.ThingGroup("basicThingGroup", {
ThingGroupName: "HomeDevices",
ParentGroupName: "Devices",
Tags: [{ Key: "Environment", Value: "Production" }]
});

Configure a ThingGroup with properties for more complex use cases, such as setting custom properties.

const advancedThingGroup = await AWS.IoT.ThingGroup("advancedThingGroup", {
ThingGroupName: "OfficeDevices",
ThingGroupProperties: {
AttributePayload: {
Attributes: {
Department: "IT",
Location: "Main Office"
},
Merge: true
}
},
Tags: [
{ Key: "Project", Value: "IoTDeployment" },
{ Key: "Owner", Value: "TeamAlpha" }
]
});

Create a ThingGroup that includes a query string to filter devices.

const queryStringThingGroup = await AWS.IoT.ThingGroup("queryStringThingGroup", {
ThingGroupName: "FilteredDevices",
QueryString: "attribute.department = 'IT'",
Tags: [{ Key: "Status", Value: "Active" }]
});

Create a ThingGroup and adopt an existing resource if it already exists.

const adoptedThingGroup = await AWS.IoT.ThingGroup("adoptedThingGroup", {
ThingGroupName: "LegacyDevices",
adopt: true // If true, adopts the existing resource instead of failing
});