AWS IoT Greengrass
Developer Guide

Configure Devices and Subscriptions

Shadows can be synced to AWS IoT when the AWS IoT Greengrass core is connected to the internet. In this module, you first use local shadows without syncing to the cloud. Then, you enable cloud syncing.

Each device has its own shadow. For more information, see Device Shadow Service for AWS IoT in the AWS IoT Developer Guide.

  1. From the Devices page, add two new devices in your AWS IoT Greengrass group. For detailed steps of this process, see Create AWS IoT Devices in an AWS IoT Greengrass Group.

    • Name the devices GG_Switch and GG_TrafficLight.

    • Generate and download the 1-Click default security resources for both devices.

    • Make a note of the hash component in the file names of the security resources for the devices. You use these values later.

     

    
                            Screenshot showing the two devices, GG_TrafficLight and
                                GG_Switch.
  2. Decompress the downloaded certificates and keys for both devices into a single folder on your computer. For example, run the following command for each .tar.gz file.

    tar -xzf hash-setup.tar.gz

    Note

    On Windows, you can decompress .tar.gz files using a tool such as 7-Zip or WinZip.

  3. Copy the root-ca-cert.pem file that you downloaded in the previous module to this folder.

  4. Make sure that the devices are set to use local shadows. If not, choose the ellipsis (), and then choose Make local only.

    
                            Screenshot with LOCAL SHADOW ONLY highlighted for both
                                devices.
  5. The function code used in this module requires that you manually configure the core's endpoint.

    1. On the group configuration page, choose Settings.

    2. For Local connection detection, choose Manually manage connection information, and then choose View Cores for specific endpoint information.

    3. Choose your core, and then choose Connectivity.

    4. Choose Edit and make sure that you have only one endpoint value. This value must be the IP address endpoint for port 8883 of your AWS IoT Greengrass core device (for example, 192.168.1.4).

    5. Choose Update.

  6. Add the subscriptions in the following table to your group. For example, to create the first subscription:

    1. On the group configuration page, choose Subscriptions, and then choose Add subscription.

    2. Under Select a source, choose Devices, and then choose GG_Switch.

    3. Under Select a target, choose Services, and then choose Local Shadow Service.

    4. Choose Next.

    5. For Topic filter, enter $aws/things/GG_TrafficLight/shadow/update

    6. Choose Next, and then choose Finish.

    The topics must be entered exactly as shown in the table. Although it's possible to use wildcards to consolidate some of the subscriptions, we don't recommend this practice. For more information, see Shadow MQTT Topics in the AWS IoT Developer Guide.

    Source Target Topic Notes

    GG_Switch

    Local Shadow Service

    $aws/things/GG_TrafficLight/shadow/update

    The GG_Switch sends an update request to update topic.

    Local Shadow Service

    GG_Switch

    $aws/things/GG_TrafficLight/shadow/update/accepted

    The GG_Switch needs to know whether the update request was accepted.

    Local Shadow Service

    GG_Switch

    $aws/things/GG_TrafficLight/shadow/update/rejected

    The GG_Switch needs to know whether the update request was rejected.

    GG_TrafficLight

    Local Shadow Service

    $aws/things/GG_TrafficLight/shadow/update

    The GG_TrafficLight sends an update of its state to the update topic.

    Local Shadow Service

    GG_TrafficLight

    $aws/things/GG_TrafficLight/shadow/update/delta

    The Local Shadow Service sends a received update to GG_TrafficLight through the delta topic.

    Local Shadow Service

    GG_TrafficLight

    $aws/things/GG_TrafficLight/shadow/update/accepted

    The GG_TrafficLight needs to know whether its state update was accepted.

    Local Shadow Service

    GG_TrafficLight

    $aws/things/GG_TrafficLight/shadow/update/rejected

    The GG_TrafficLight needs to know whether its state update was rejected.

    The new subscriptions are displayed on the Subscriptions page. To see the full topic path of a subscription, hover your mouse over the Topic column.

    
                            Tabular data on the Subscriptions page. The page contains
                                Source, Target, and Topic columns.

    Note

    For information about the $ character, see Reserved Topics.

  7. Make sure that the AWS IoT Greengrass daemon is running, as described in Deploy Cloud Configurations to a Core Device.

  8. On the group configuration page, from Actions, choose Deploy to deploy the group configuration to your AWS IoT Greengrass core device.

    
                Screenshot of the Group page with the Deploy action 
                    highlighted.

    For troubleshooting help, see Troubleshooting AWS IoT Greengrass.