AWS IoT Greengrass
Developer Guide

Test Communications

  1. On your computer, open two command-line windows. Just as in Module 5, one window is for the GG_Switch device and the other is for the GG_TrafficLight device. You use them to run the same commands that you ran in Module 5.

    Run the following commands for the GG_Switch device:

    cd path-to-certs-folder python --endpoint AWS_IOT_ENDPOINT --rootCA root-ca-cert.pem --cert switch.cert.pem --key switch.private.key --thingName GG_TrafficLight --clientId GG_Switch

    Run the following commands for the GG_TrafficLight device:

    cd path-to-certs-folder python --endpoint AWS_IOT_ENDPOINT --rootCA root-ca-cert.pem --cert light.cert.pem --key light.private.key --thingName GG_TrafficLight --clientId GG_TrafficLight

    Every 20 seconds, the switch updates the shadow state to G, Y, and R, and the light displays its new state.

  2. The function handler of the Lambda function is triggered on every third green light (every three minutes), and a new DynamoDB record is created. After and have run for three minutes, go to the AWS Management Console, and open the DynamoDB console.

  3. Make sure that the N. Virginia (us-east-1) region is selected. Choose Tables and then choose the CarStats table.

                            Screenshots of DynamoDB console with CarStats and Items tab

    On the Items tab, you should see entries with basic statistics on cars passed (one entry for every three minutes). You might need to choose the refresh button to view updates to the table.

                            DynamoDB CarStats screenshot showing multiple record


    If necessary, you can troubleshoot issues by viewing the AWS IoT Greengrass core logs, particularly runtime.log:

    cd /greengrass/ggc/var/log sudo cat system/runtime.log | more

    You can also view the user Lambda log generated by your Lambda function. Look for the function log in the following folder:

    cd /greengrass/ggc/var/log/user/your-region/your-account-id/your-function-name

    For more information, see Troubleshooting AWS IoT Greengrass.

You have reached the end of this tutorial and should now understand the AWS IoT Greengrass programming model and its fundamental concepts, including AWS IoT Greengrass cores, groups, subscriptions, and the deployment process for Lambda functions running at the edge.

You can delete the DynamoDB table and the Lambda functions, and stop communications between the AWS IoT Greengrass core device and the AWS IoT cloud. To stop communications, open a terminal on the AWS IoT Greengrass core device and run one of the following commands:

  • To shut down the AWS IoT Greengrass core device:

    sudo halt
  • To stop the AWS IoT Greengrass daemon:

    cd /greengrass/ggc/core/ sudo ./greengrassd stop