MISC-TN-020: Running AWS IoT Greengrass Core version 2 on SBCSPG

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box
SBCSPG-1.jpg Applies to SBCSPG
Cloud-computing-banner.jpg Applies to IoT
Warning-icon.png This technical note was validated against specific versions of hardware and software. It may not work with other versions. Warning-icon.png


History[edit | edit source]

Version Date Notes
1.0.0 July 2021 First public release

Introduction[edit | edit source]

In 2019, the Technical Note (TN) MISC-TN-005: Running AWS Greengrass Core on SBCSPG was published. It describes how to run AWS IoT Greengrass Core version 1 on SBCSPG industrial gateway equipped with Armbian Stretch distribution. This TN is very similar, but it illustrates how to run version 2 instead. The hardware platform is the same used in MISC-TN-005, but the Linux distribution is Armbian Buster.

Essentially, the procedure that was followed is the one described in the Getting started with AWS IoT Greengrass V2 document.

Installing Greengrass Core version 2 on the core device[edit | edit source]

After ìnstalling and configuring the AWS CLI version 1 ...


armbian@sbcspg:~$ aws --version
aws-cli/1.19.111 Python/3.7.3 Linux/4.1.15-rialto-1.1.6 botocore/1.20.111
armbian@sbcspg:~/devel/aws/tmp$ aws configure
AWS Access Key ID [********************]: 
AWS Secret Access Key [********************]: 
Default region name [eu-south-1]: us-east-1
Default output format [json]:


... the default-jdk package was installed:


armbian@sbcspg:~$ java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-post-Debian-1deb10u1)
OpenJDK Server VM (build 11.0.11+9-post-Debian-1deb10u1, mixed mode)


Then, the AWS IoT Greengrass Core (GGC) software version 2 was downloaded and installed:


armbian@sbcspg:~/devel/aws/tmp$ sudo -E java -Droot="/opt/greengrass/v2" -Dlog.store=FILE   -jar ./GreengrassCore/lib/Greengrass.jar   --aws-region us-east-1   --thing-name sbcspg0   --thing-group-name sbcspg   --tes-role-name GreengrassV2TokenExchangeRole   --tes-role-alias-name GreengrassCoreTokenExchangeRoleAlias   --component-default-user ggc_user:ggc_group   --provision true   --setup-system-service true   --deploy-dev-tools true
Provisioning AWS IoT resources for the device with IoT Thing Name: [sbcspg0]...
Creating new IoT policy "GreengrassV2IoTThingPolicy"
Creating keys and certificate...
Attaching policy to certificate...
Creating IoT Thing "sbcspg0"...
Attaching certificate to IoT thing...
Successfully provisioned AWS IoT resources for the device with IoT Thing Name: [sbcspg0]!
Adding IoT Thing [sbcspg0] into Thing Group: [sbcspg]...
Successfully added Thing into Thing Group: [sbcspg]
Setting up resources for aws.greengrass.TokenExchangeService ... 
TES role alias "GreengrassCoreTokenExchangeRoleAlias" does not exist, creating new alias...
TES role "GreengrassV2TokenExchangeRole" does not exist, creating role...
IoT role policy "GreengrassTESCertificatePolicyGreengrassCoreTokenExchangeRoleAlias" for TES Role alias not exist, creating policy...
Attaching TES role policy to IoT thing...
No managed IAM policy found, looking for user defined policy...
No IAM policy found, will attempt creating one...
IAM role policy for TES "GreengrassV2TokenExchangeRoleAccess" created. This policy DOES NOT have S3 access, please modify it with your private components' artifact buckets/objects as needed when you create and deploy private components 
Attaching IAM role policy for TES to IAM role for TES...
Configuring Nucleus with provisioned resource details...
Downloading Root CA from "https://www.amazontrust.com/repository/AmazonRootCA1.pem"
Created device configuration
Successfully configured Nucleus with provisioned resource details!
Creating a deployment for Greengrass first party components to the thing group
Configured Nucleus to deploy aws.greengrass.Cli component
Successfully set up Nucleus as a system service

Testing the installation[edit | edit source]

To test the installation, on the development computer it is possibile to verify that the core device was registered successfully:

user@nimbus:~/devel/sbcspg/backup$ aws greengrassv2 list-core-devices
{
    "coreDevices": [
        {
            "coreDeviceThingName": "sbcspg0",
            "status": "HEALTHY",
            "lastStatusUpdateTimestamp": 1626271065.488
        }
    ]
}


On the core device, the simple "HelloWorld" example was run as per AWS's documentation:

armbian@sbcspg:~/devel/aws/tmp/GreengrassCore$ sudo /opt/greengrass/v2/bin/greengrass-cli deployment create   --recipeDir ~/devel/aws/tmp/GreengrassCore/recipes   --artifactDir ~/devel/aws/tmp/GreengrassCore/artifacts   --merge "com.example.HelloWorld=1.0.0"
AWS libcrypto resolve: searching process and loaded modules
AWS libcrypto resolve: found static aws-lc HMAC symbols
AWS libcrypto resolve: found static aws-lc libcrypto 1.1.1 EVP_MD symbols
Jul 14, 2021 4:24:21 PM software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection$1 onConnectionSetup
INFO: Socket connection /opt/greengrass/v2/ipc.socket:8033 to server result [AWS_ERROR_SUCCESS]
Jul 14, 2021 4:24:24 PM software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection$1 onProtocolMessage
INFO: Connection established with event stream RPC server
Local deployment submitted! Deployment Id: 0d98a390-9b41-4009-975b-81fe783a833a
armbian@sbcspg:~/devel/aws/tmp/GreengrassCore$ sudo /opt/greengrass/v2/bin/greengrass-cli component restart \
>   --names "com.example.HelloWorld"
AWS libcrypto resolve: searching process and loaded modules
AWS libcrypto resolve: found static aws-lc HMAC symbols
AWS libcrypto resolve: found static aws-lc libcrypto 1.1.1 EVP_MD symbols
Jul 14, 2021 4:25:36 PM software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection$1 onConnectionSetup
INFO: Socket connection /opt/greengrass/v2/ipc.socket:8033 to server result [AWS_ERROR_SUCCESS]
Jul 14, 2021 4:25:39 PM software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection$1 onProtocolMessage
INFO: Connection established with event stream RPC server
armbian@sbcspg:~/devel/aws/tmp/GreengrassCore$ tail -f /tmp/Greengrass_HelloWorld.log
Hello, world! Current time: 2021-07-14 16:17:41.478436.
Hello, world! Current time: 2021-07-14 16:25:41.232316. Greetings from your first Greengrass component.
armbian@sbcspg:~$ aws greengrassv2 list-effective-deployments --core-device-thing-name sbcspg0
{
    "effectiveDeployments": [
        {
            "deploymentId": "d4f58fb1-68e7-45f4-86e0-d47bc5cfa232",
            "deploymentName": "Deployment for sbcspg",
            "iotJobId": "d56f5e70-70de-4418-9cca-41815168ec55",
            "iotJobArn": "arn:aws:iot:us-east-1:472670657019:job/d56f5e70-70de-4418-9cca-41815168ec55",
            "targetArn": "arn:aws:iot:us-east-1:472670657019:thinggroup/sbcspg",
            "coreDeviceExecutionStatus": "SUCCEEDED",
            "reason": "SUCCESSFUL",
            "creationTimestamp": 1626270714.524,
            "modifiedTimestamp": 1626270714.524
        }
    ]
}