Skip to content
GitHubXDiscordRSS

DeviceDefinition

Learn how to create, update, and manage AWS Greengrass DeviceDefinitions using Alchemy Cloud Control.

The DeviceDefinition resource allows you to manage AWS Greengrass DeviceDefinitions that define a group of devices in your Greengrass environment.

Create a basic DeviceDefinition with required properties and an initial version.

import AWS from "alchemy/aws/control";
const basicDeviceDefinition = await AWS.Greengrass.DeviceDefinition("basicDeviceDef", {
name: "BasicDeviceDefinition",
initialVersion: {
devices: [
{
id: "MyDevice",
thingArn: "arn:aws:iot:us-west-2:123456789012:thing/MyDevice"
}
]
},
tags: {
Environment: "Development"
}
});

Create a DeviceDefinition with multiple devices and additional tags for better organization.

const advancedDeviceDefinition = await AWS.Greengrass.DeviceDefinition("advancedDeviceDef", {
name: "AdvancedDeviceDefinition",
initialVersion: {
devices: [
{
id: "TemperatureSensor",
thingArn: "arn:aws:iot:us-west-2:123456789012:thing/TemperatureSensor"
},
{
id: "HumiditySensor",
thingArn: "arn:aws:iot:us-west-2:123456789012:thing/HumiditySensor"
}
]
},
tags: {
Environment: "Production",
Project: "SmartHome"
}
});

Create a DeviceDefinition that adopts existing resources instead of failing when the resource already exists.

const adoptDeviceDefinition = await AWS.Greengrass.DeviceDefinition("adoptDeviceDef", {
name: "AdoptedDeviceDefinition",
initialVersion: {
devices: [
{
id: "ExistingDevice",
thingArn: "arn:aws:iot:us-west-2:123456789012:thing/ExistingDevice"
}
]
},
adopt: true,
tags: {
Environment: "Testing"
}
});

Demonstrate how to update an existing DeviceDefinition with additional devices.

const updatedDeviceDefinition = await AWS.Greengrass.DeviceDefinition("updateDeviceDef", {
name: "UpdatedDeviceDefinition",
initialVersion: {
devices: [
{
id: "NewSensor",
thingArn: "arn:aws:iot:us-west-2:123456789012:thing/NewSensor"
}
]
},
tags: {
Environment: "Staging",
UpdatedBy: "DevTeam"
}
});