How to use CloudFormaiton to create IOT Thing Group

0

I cannot find in the documentation on how to use cloudformation to create-thing-group. Is this possible?

已提問 2 年前檢視次數 596 次
3 個答案
1

I couldn't find any update to the CDK spec on this or on adding things to thing groups. I had to go with custom resources, like below:

   const myThingGroup = new cr.AwsCustomResource(this, 'my-thing-group', {
      onCreate: {
        service: 'Iot',
        action: 'createThingGroup',
        parameters: {
          thingGroupName: 'my-tg-name'
        },
        physicalResourceId: cr.PhysicalResourceId.of(Date.now().toString()),
      },
      onDelete: {
        service: 'Iot',
        action: 'deleteThingGroup',
        parameters: {
          thingGroupName: 'my-tg-name'
        },
      },
      policy: cr.AwsCustomResourcePolicy.fromSdkCalls({
        resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE,
      }),
    });

When I added and removed things to/from thing groups, I needed to use addDependency otherwise cdk destroy failed, like this:

    myThingThingGroupDetachment.node.addDependency(myThing)
    myThingThingGroupDetachment.node.addDependency(myThingGroup)

Hope this saves some time for someone.

gary
已回答 1 年前
0

At this moment, we have to either create custom resources or use the APIs.

profile pictureAWS
專家
已回答 2 年前
0

Meanwhile, a CfnThingGroup resource is available.

AWS
robhan
已回答 3 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南