FlowTemplate
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.
Minimal Example
Section titled “Minimal Example”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});
Advanced Configuration
Section titled “Advanced Configuration”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});
Utilizing FlowTemplates in Applications
Section titled “Utilizing FlowTemplates in Applications”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 FlowTemplateconst deployApp = async () => { // Logic to deploy the flow template console.log(`FlowTemplate ${appFlowTemplate.id} deployed successfully.`);};
deployApp();
Managing FlowTemplate Updates
Section titled “Managing FlowTemplate Updates”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});