RZ/G3S - AWS Greengrass Connection
- 1 Step 1 - AWS Cloud - RZ/G3S Connection
- 2 Step 2 - AWS Greengrass Nucleus version update
- 3 Step 3 - IAM Role & Policy creation
- 4 Step 4 - How to upload the Temp & Humidity sensor (PMOD) python sample code
- 5 Step 5 - Sample Application Component Preparation
- 6 Step 6 - Deployment of AWS Greengrass Component
- 7 Step 7 - How to check MQTT data from RZ/G3S
Step 1 - AWS Cloud - RZ/G3S Connection
Assumption:
AWS account is created and active - How to Create an AWS Account
User have build the Linux environment according to this procedure
Search for IoT Greengrass
On AWS IoT > Manage > Greengrass devices tab, select Set up on core device
Follow the instruction of Greengrass core device
Step 1: Core device name
Step 2: For demo purpose select "No group"
Step 3.1:
・Select Core software runtime: "Nucleus Classic"
・"Linux" Operating System
・"Set up a device with installer download"
Step 3.2 & Step 3.3:
・Click "Create thing"
・Click "Download connection Kit"
・Click "Download Installer"
Step 3.4: Unzip and Copy downloaded items content into your SD card
・Create "GreengrassInstaller" directory in /home/root/ and copy the installer content in it
・Copy the connection kit content in the /greengrass/v2 folder
・[RZ/G3S Board] Run the following command after booting up the board:sed -i 's|{{config_dir}}|/greengrass/v2|g; s|{{nucleus_component}}|aws.greengrass.Nucleus|g' /greengrass/v2/config.yaml && sudo -E java -Droot="/greengrass/v2" -Dlog.store=FILE -jar ./GreengrassInstaller/lib/Greengrass.jar --init-config /greengrass/v2/config.yaml --component-default-user ggc_user:ggc_group --setup-system-service trueWhen succesful the following message should appear:
[AWS Console] Check on AWS IoT > Manage > Greengrass devices > Core devices: Check that your device status is "healthy"
Step 2 - AWS Greengrass Nucleus version update
The Nucleus version build is old and can be the cause of errors in the following steps.
On RZ/G3S Board
Stop running AWS Greengrass service 2.9.6 on RZ/G3S
systemctl stop greengrass.serviceExport the AWS Keys:
export AWS_ACCESS_KEY_ID= <Access Key ID>
export AWS_SECRET_ACCESS_KEY= <Secret Access Key>On AWS Console
More information & access key manage for IAM user are described here: Manage access keys for IAM users - AWS Identity and Access Management
User can create the above key from the "security credentials" as show below:
Start the Greengrass service on RZ/G3S using below command with region and thing-name. This command needs super user(sudo) permissions:
java -Droot="/greengrass/v2" -Dlog.store=FILE -jar /greengrass/v2/alts/current/distro/lib/Greengrass.jar --aws-region <Region> --thing-name <core_device_name> --component-default-user ggc_user:ggc_group --provision true --setup-system-service true --deploy-dev-tools trueExample
java -Droot="/greengrass/v2" -Dlog.store=FILE -jar /greengrass/v2/alts/current/distro/lib/Greengrass.jar --aws-region ap-southeast-1 --thing-name RZG3S_device --component-default-user ggc_user:ggc_group --provision true --setup-system-service true --deploy-dev-tools true Above command may take 2 to 3 minutes to create thing on AWS IoT and get the endpoints and token exchange role.
The above java command is a one time operation which creates core device, provisioning the device and starts the Greengrass service v2.9.6 automatically.
Next boot onwards the Greengrass core service v2.9.6 starts automatically and uses the created core device without any manual commands.
On AWS Console
From AWS Greengrass dashboard, user can update the Nucleus and Greengrass-cli from v2.9.6 to a later version using deployments.
If Nucleus and greengrass-cli updates successfully, then all deployed components are updated to later suitable versions.
Follow the following steps:
Select "Deployments" in "AWS IoT > Manage > Greengrass devices"
Click the "Create" button
Step 1: Specify Target
・Deployment Name
・Deployment target type: "Core device" & Target Name
・Click "Next"
Step 2: Select components
From "Public components" tab, select "aws.greengrass.Cli", "aws.greengrass.Nucleus" and "aws.greengrass.TokenExchangeService" and click "Next"
Step 3: Configure components
・Tick "aws.greengrass.Nucleus" and click "Configure component"
・Modify "Component version" to … and click "Confirm"
・Click "Next"
Do the same for "aws.greengrass.cli" to the same version as nucleus
Step 4: Configure Advanced Settings
Configure Deployment policies as below:
Step 5: Review content and click "Deploy"
Deployment should take a few minutes and following status will show up if successful: "Completed" status will appear
In device Overview section check that Nucleus version was updated