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?

3 Respuestas
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
respondido hace un año
0

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

profile pictureAWS
EXPERTO
respondido hace 2 años
0

Meanwhile, a CfnThingGroup resource is available.

AWS
robhan
respondido hace 3 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas