'AWS IOT Greengrass 2 Raspberry Pi Deployment

I am trying to follow the step-by-step instruction to set-up a raspberry-pi zero 2 as an IoT device using AWS Greengrass. I found a really nice instruction published at YouTube - Build a DIY Mars Probe using AWS Greengrass IoT v2 with a Raspberry Pi | ACG Projects (https://www.youtube.com/watch?v=Ity2Z03Lp1k).

I was able to follow all instruction and finally tried to test the connection with the MQTT test client. However, after I pinged it, it didn't show anything. When I reboot the raspberry-pi, the MQTT console shows the following messages showing that the SnapPicture.py is broken.

$aws/things/RealPi2/shadow/name/AWSManagedGreengrassV2Deployment/get

{
  "shadowName": "AWSManagedGreengrassV2Deployment",
  "thingName": "RealPi2"
}
$aws/things/RealPi2/shadow/name/AWSManagedGreengrassV2Deployment/get/accepted

{
  "state": {
    "desired": {
      "fleetConfig": "{\"deploymentId\":\XXXXXXXXXXXXXXXXXX\",\"schemaDate\":\"2021-05-17\",\"deploymentName\":\"Deployment for RealPi2\",\"configurationArn\":\"arn:aws:greengrass:us-west-2:953054857915:configuration:thing/RealPi2:9\",\"creationTimestamp\":1639762626973,\"components\":{\"aws.greengrass.Cli\":{\"version\":\"2.5.2\"},\"snapPicture\":{\"version\":\"1.0.0\",\"configurationUpdate\":{\"merge\":{\"jvmOptions\":\"-Xmx64m -XX:+UseSerialGC -XX:TieredStopAtLevel=1\"}},\"runWith\":{}},\"aws.greengrass.Nucleus\":{\"version\":\"2.5.2\",\"configurationUpdate\":{\"merge\":{\"jvmOptions\":\"-Xmx64m -XX:+UseSerialGC -XX:TieredStopAtLevel=1\"}},\"runWith\":{}}},\"failureHandlingPolicy\":\"DO_NOTHING\",\"requiredCapabilities\":[],\"componentUpdatePolicy\":{\"timeout\":60,\"action\":\"NOTIFY_COMPONENTS\"},\"configurationValidationPolicy\":{\"timeout\":60}}",
      "desiredStatus": "COMPLETED"
    },
    "reported": {
      "ggcVersion": "2.5.2",
      "fleetConfigurationArnForStatus": "arn:aws:greengrass:us-west-2:953054857915:configuration:thing/RealPi2:9",
      "statusDetails": {
        "detailedStatus": "SUCCESSFUL",
        "failureCause": "Service snapPicture in broken state after deployment"
      },
      "status": "SUCCEEDED"
    },
    "delta": {
      "fleetConfig": "{\"deploymentId\":\"9d0fa215-d1ca-40b1-b361-73820b7a669b\",\"schemaDate\":\"2021-05-17\",\"deploymentName\":\"Deployment for RealPi2\",\"configurationArn\":\"arn:aws:greengrass:us-west-2:953054857915:configuration:thing/RealPi2:9\",\"creationTimestamp\":1639762626973,\"components\":{\"aws.greengrass.Cli\":{\"version\":\"2.5.2\"},\"snapPicture\":{\"version\":\"1.0.0\",\"configurationUpdate\":{\"merge\":{\"jvmOptions\":\"-Xmx64m -XX:+UseSerialGC -XX:TieredStopAtLevel=1\"}},\"runWith\":{}},\"aws.greengrass.Nucleus\":{\"version\":\"2.5.2\",\"configurationUpdate\":{\"merge\":{\"jvmOptions\":\"-Xmx64m -XX:+UseSerialGC -XX:TieredStopAtLevel=1\"}},\"runWith\":{}}},\"failureHandlingPolicy\":\"DO_NOTHING\",\"requiredCapabilities\":[],\"componentUpdatePolicy\":{\"timeout\":60,\"action\":\"NOTIFY_COMPONENTS\"},\"configurationValidationPolicy\":{\"timeout\":60}}",
      "desiredStatus": "COMPLETED"
    }
  },
  "metadata": {
    "desired": {
      "fleetConfig": {
        "timestamp": 1639762627
      },
      "desiredStatus": {
        "timestamp": 1639762627
      }
    },
    "reported": {
      "ggcVersion": {
        "timestamp": 1639762672
      },
      "fleetConfigurationArnForStatus": {
        "timestamp": 1639762672
      },
      "statusDetails": {
        "detailedStatus": {
          "timestamp": 1639762672
        },
        "failureCause": {
          "timestamp": 1639422348
        }
      },
      "status": {
        "timestamp": 1639762672
      }
    }
  },
  "version": 28,
  "timestamp": 1639922924
}

I independently ran snapPicture.py with parameters and the results are following.

Traceback (most recent call last):
  File "snapPicture.py", line 29, in <module>
    ipc_client = awsiot.greengrasscoreipc.connect()
  File "/home/pi/.local/lib/python3.7/site-packages/awsiot/greengrasscoreipc/__init__.py", line 45, in connect
    ipc_socket = os.environ["AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT"]
  File "/usr/lib/python3.7/os.py", line 678, in __getitem__
    raise KeyError(key) from None
KeyError: 'AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT'

My suspicion is that ipc_client = awsiot.greengrasscoreipc.connect() is not working properly.

Any advice would be greatly appreciated.

SMP



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source