Skip to content
GitHubXDiscordRSS

FlowTemplate

Learn how to create, update, and manage AWS IoTThingsGraph FlowTemplates using Alchemy Cloud Control.

The FlowTemplate resource allows you to define and manage AWS IoTThingsGraph FlowTemplates which represent a reusable and versioned set of workflows in your IoT applications.

This example demonstrates how to create a basic FlowTemplate with required properties and a common optional property.

import AWS from "alchemy/aws/control";
const simpleFlowTemplate = await AWS.IoTThingsGraph.FlowTemplate("SimpleFlowTemplate", {
Definition: {
// Basic definition document structure
language: "EN",
schema: {
// Define your schema here
}
},
CompatibleNamespaceVersion: 1 // Optional property
});

This example shows how to create a FlowTemplate with a more complex definition and adoption of existing resources.

const complexFlowTemplate = await AWS.IoTThingsGraph.FlowTemplate("ComplexFlowTemplate", {
Definition: {
language: "EN",
schema: {
// Define your schema here
entities: [
{
name: "TemperatureSensor",
type: "Sensor",
properties: {
temperature: {
type: "Number"
}
}
}
]
}
},
CompatibleNamespaceVersion: 2, // Optional property
adopt: true // Adopt existing resource if it exists
});

This example demonstrates how to utilize the created FlowTemplate in an IoT application context.

const appFlowTemplate = await AWS.IoTThingsGraph.FlowTemplate("AppFlowTemplate", {
Definition: {
language: "EN",
schema: {
entities: [
{
name: "DoorLock",
type: "Actuator",
properties: {
lockState: {
type: "Boolean"
}
}
}
]
}
}
});
// Further application logic using the FlowTemplate
const deployApp = async () => {
// Logic to deploy the flow template
console.log(`FlowTemplate ${appFlowTemplate.id} deployed successfully.`);
};
deployApp();

This example illustrates how to update an existing FlowTemplate with new definitions.

const updatedFlowTemplate = await AWS.IoTThingsGraph.FlowTemplate("UpdatedFlowTemplate", {
Definition: {
language: "EN",
schema: {
entities: [
{
name: "UpdatedSensor",
type: "Sensor",
properties: {
humidity: {
type: "Number"
}
}
}
]
}
},
CompatibleNamespaceVersion: 3 // Update to a new compatible version
});