This article will introduce the first steps to run AWS IoT Greengrass software in Toradex modules with Torizon.
The use of an AWS Region that supports AWS IoT Greengrass.
In addition, you need to follow these guides on AWS page:
Configure the Lambda Function for AWS IoT Greengrass for a run on a Torizon container. To do this go to the settings of your Greengrasss Group:
Select the option Default Lamda function containerization to No container and clik the button Update default Lambda execution configuration:
A confirmation window will be shown, click Continue button:
After setting up the AWS IoT Greengrass on your AWS IoT and after you download the security resources, copy the security resources file to the board via ssh:
$ scp hash-setup.tar.gz torizon@board_ip:/home/torizon
From the above command example, remember to change board_ip for the Toradex the module IP address.
Access the board Bash via ssh:
$ ssh torizon@board_ip
Unzip the security resources file:
# sudo tar -xzvf hash-setup.tar.gz
To obtain the docker-compose.yml required you can simply copy the file found in our samples repository here.
Note: Copy docker-compose file in the same root directory where you unzipped the security resources files on the target Torizon device.
Execute the docker-compose to run the container with the AWS IoT Greengrass Core software for Torizon:
# docker-compose run --rm greengrass
If you have output containing the message:
Note: More message logs may be output with this message.
Greengrass successfully started with PID
The message above means the AWS IoT Greengrass Core software for Torizon is running successfully.
Deploy the cloud configuration from AWS Greengrass Group to the board. On your Greengrass group access Deployments and click on Actions, Deploy:
The first time you are deploying a Configure how Devices discover your Core will be shown, click the Automatic detection button:
Wait a while for the deploy to complete. If all goes successfully you will see the following status:
Test if your Lambda function running on the device is successfully sending MQTT messages. In the AWS Console IoT Core menu select Test, on the Subscription topic input field write "hello/world" and finally click the Subscribe to topic button:
If the connection between device and AWS IoT Core was made correctly you should see messages coming from the device: