4

From the documentation, there is a syntax for creating things in AWS IoT but I can't find how to connect it to Things Type. Is it possible to write it like this?

AWSTemplateFormatVersion: "2010-09-09"
Resources: 
  MyThing: 
    Type: "AWS::IoT::Thing"
    Properties: 
      ThingName: "coffeemachine-12"
      ThingType: "coffeemachine"
      AttributePayload: 
        Attributes: 
          temp: "celcius"

How do I configure/create AWS IoT Thing Types in AWS CloudFormation template?

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
DrSensor
  • 487
  • 6
  • 18
  • If you want to create thing type via cloudformation, you would have to use custom resources in CloudFormation template. Basically, you have a lambda that will be responsible for creating the iot thing type resources. – brushtakopo Feb 01 '23 at 12:08

2 Answers2

2

You can't currently manage thing types via CloudFormation. You can, however, reference existing thing types when creating things.

The semantics of thing types don't lend themselves to automation via CloudFormation. For example :

  • They are immutable
  • Deletion requires deprecation, followed by a 5-minute cool down period.

This is undoubtedly why they aren't supported by CloudFormation.

Paul Lalonde
  • 5,020
  • 2
  • 32
  • 35
-1

Are you asking about how to make ThingType configurable when updating the CloudFormation stack?

If so, you might want to do something like:

Parameters:
  ThingType:
    Description: 'Description for ThingType'
    Type: String

Resources: 
  MyThing: 
    Type: "AWS::IoT::Thing"
    Properties: 
      ThingName: "coffeemachine-12"
      ThingType: !Ref ThingType
      AttributePayload: 
        Attributes: 
          temp: "celcius"

basically, you declare ThingType as a parameter and add the reference to this variable when create your resources.

Hope that helps

PennTao
  • 11
  • 2
  • 1
    There is no "ThingType" property in the AWS::IoT::Thing resource. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-thing.html – Bruno Negrão Zica May 10 '19 at 19:23