Understanding Device Shadow Service in AWS IoT Core

   Go back to the Task List

  « 4. Get the shadow document    6. Clean up »

5. Delete the shadow document

Having worked with update and get operations, let’s try to delete the shadow document for the device.

  1. On the AWS IoT Core console, click on the Test menu. You see the MQTT Client which you can use to publish and subscribe to the topics.

    MQTT Client

  2. When you publish empty message to the $aws/things/dojodevice1/shadow/delete topic, AWS IoT core publishes the delete confirmation message to the $aws/things/dojodevice1/shadow/delete/accepted topic. If the delete fails, a message is published to the $aws/things/dojodevice1/shadow/delete/rejected topic.

  3. You will add subscriptions for $aws/things/dojodevice1/shadow/delete/accepted and $aws/things/dojodevice1/shadow/delete/rejected topics in the same way you did earlier.

    MQTT Client

    MQTT Client

  4. Next, publish empty message to the $aws/things/dojodevice1/shadow/delete topic.

    MQTT Client

  5. The moment the message is published, you will see a green dot next to the $aws/things/dojodevice1/shadow/delete/accepted topic. It means there is a new message published to this topic.

    MQTT Client

  6. Click on the $aws/things/dojodevice1/shadow/delete/accepted topic to check the message which shows the version and timestamp of the shadow document deleted.

    MQTT Client

  7. You can verify the delete by looking at the shadow document for the device. As mentioned in the task-2, open the details for the device dojodevice1 and goto the Shadows menu to check the shadow document of the device.

    Before delete

    Shadow

    After delete

    Shadow

  8. That finishes the workshop. You worked on all three operations - update, get and delete. Please go to the next step to clean the resources so that you incur no cost after the workshop.