RZ/G2L - AWS Greengrass Connection

RZ/G2L - AWS Greengrass Connection

Step 1 - AWS Cloud - RZ/G2L Connection


Assumption:
    AWS account is created and active - How to Create an AWS Account
    User have build the Linux environment according to this procedure 

  1. Search for IoT Greengrass

  2. On AWS IoT > Manage > Greengrass devices tab, select Set up on core device 

  3. Follow the instruction of Greengrass core device
    Step 1: Core device name: i.e. "RZG2L_Device"


    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/G 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 true

    When succesful the following message should appear:

  4.  [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/G Board

Stop running AWS Greengrass service 2.9.6 on RZ/G

systemctl stop greengrass.service

Export 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/G 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 true

Example

java -Droot="/greengrass/v2" -Dlog.store=FILE -jar /greengrass/v2/alts/current/distro/lib/Greengrass.jar --aws-region ap-southeast-1 --thing-name RZG2L_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 (If necessary)
・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