DeviceDefinition
The DeviceDefinition resource allows you to manage AWS Greengrass DeviceDefinitions that define a group of devices in your Greengrass environment.
Minimal Example
Section titled “Minimal Example”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" }});
Advanced Configuration
Section titled “Advanced Configuration”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" }});
Device Adoption
Section titled “Device Adoption”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" }});
Updating Device Definitions
Section titled “Updating Device Definitions”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" }});