Skip to content

Latest commit

 

History

History
230 lines (226 loc) · 13.5 KB

File metadata and controls

230 lines (226 loc) · 13.5 KB

Installation Instructions

  1. Install OS (Jessie-Lite Sept) on three hosts.

    Note: this demo has been built using Raspberry Pi 3 computers

  2. Configure the three hosts to be on the same network and note each host's IP

  3. On each host make a ~/mini-fulfillment directory

  4. Back on your development machine, execute the following steps.

    1. Install the AWS CLI and configure it with Administrator credentials.
    2. Clone this git repo into a directory ~/aws-greengrass-mini-fulfillment/
      • Example: git clone https://github.com/awslabs/aws-greengrass-mini-fulfillment.git ~/aws-greengrass-mini-fulfillment

      Note: All subsequent instructions assume the developer's local copy of this repository is in ~/aws-greengrass-mini-fulfillment/ if you chose another directory, remember to take that into account throughout these instructions.

    3. From the top of the repository at ~/aws-greengrass-mini-fulfillment/:
      • Install a virtual environment: virtualenv venv --python=python2.7
      • Activate the virtual environment: source venv/bin/activate
      • Execute: pip install -r requirements.txt
    4. Create the three Greengrass Core things and attach certificates in AWS IoT. Specifically, to create the Greengrass Cores for this example:
      cd ~/aws-greengrass-mini-fulfillment/groups
      ./group_setup.py create-core --thing-name sort_arm-core --config-file arm/sort_arm/cfg.json --cert-dir arm/sort_arm
      ./group_setup.py create-core --thing-name inv_arm-core --config-file arm/inv_arm/cfg.json --cert-dir arm/inv_arm
      ./group_setup.py create-core --thing-name master-core --config-file master/cfg.json --cert-dir master/certs

      Note: You can see the details of each created Core recorded in the cfg.json files used above in the create-core command. Example:

      {
        "core": {
          "cert_arn": "arn:aws:iot:us-west-2:EXAMPLE_ACCT:cert/EXAMPLE10bEXAMPLE34e3a3ac96f3903d040fcca1f7b6e83aba15d95a631622b",
          "cert_id": "EXAMPLE10bEXAMPLE34e3a3ac96f3903d040fcca1f7b6e83aba15d95a631622b",
          "thing_arn": "arn:aws:iot:us-west-2:EXAMPLE_ACCT:thing/sort_arm-core",
          "thing_name": "sort_arm-core"
        },...
    5. Download the root-ca file used by all three cores to communicate with the AWS cloud. Then copy that root-ca to the proper directories:
      cd ~/aws-greengrass-mini-fulfillment/groups
      curl -o root-ca.pem https://www.symantec.com/content/en/us/enterprise/verisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem
      echo arm/sort_arm arm/sort_arm/ggd_certs | xargs -n 1 cp root-ca.pem
      echo arm/inv_arm arm/inv_arm/ggd_certs | xargs -n 1 cp root-ca.pem
      echo master/certs master/ggd/certs | xargs -n 1 cp root-ca.pem
      rm root-ca.pem
    6. Create the Greengrass Device things and certificates in AWS IoT as follows:
      ./group_setup.py create-devices --thing-names '[sort_arm_ggd,sort_heartbeat_ggd]' --config-file arm/sort_arm/cfg.json --cert-dir arm/sort_arm/ggd_certs
      ./group_setup.py create-devices --thing-names '[inv_arm_ggd,inv_heartbeat_ggd]' --config-file arm/inv_arm/cfg.json --cert-dir arm/inv_arm/ggd_certs
      ./group_setup.py create-devices --thing-names '[button_ggd,belt_ggd,bridge_ggd,heartbeat_ggd,web_ggd]' --config-file master/cfg.json --cert-dir master/ggd/certs
      ./group_setup.py create-devices --thing-names '[master_brain]' --config-file master/cfg.json --cert-dir master/ggd/certs --append True --cloud_sync True
      ./group_setup.py associate-devices --thing-names '[inv_arm_ggd,sort_arm_ggd]' --config-file master/cfg.json
      ./group_setup.py associate-devices --thing-names '[bridge_ggd]' --config-file arm/sort_arm/cfg.json
      ./group_setup.py associate-devices --thing-names '[bridge_ggd]' --config-file arm/inv_arm/cfg.json

      Note: You can see the details of each create Device recorded in the cfg.json files used above in the create-devices command. Example:

        ...
        "devices": {
          "sort_arm_ggd": {
            "cert_arn": "arn:aws:iot:us-west-2:EXAMPLE_ACCT:cert/EXAMPLEba1EXAMPLE32b63db0d3a830b7874dcb791cc045ad9bc7c64a058c87e",
            "cert_id": "EXAMPLEba1EXAMPLE32b63db0d3a830b7874dcb791cc045ad9bc7c64a058c87e",
            "thing_arn": "arn:aws:iot:us-west-2:EXAMPLE_ACCT:thing/sort_arm_ggd",
            "thing_name": "sort_arm_ggd"
          },...
    7. Create the Greengrass Group's Lambda functions
      ./lambda_setup.py create lambda/MasterBrain/cfg_lambda.json
      ./lambda_setup.py create lambda/MasterErrorDetector/cfg_lambda.json
      ./lambda_setup.py create lambda/ArmErrorDetector/cfg_lambda.json
    8. Associate the Lambda functions with the proper Greengrass Groups
      ./group_setup.py associate-lambda ./arm/sort_arm/cfg.json ./lambda/ArmErrorDetector/cfg_lambda.json
      ./group_setup.py associate-lambda ./arm/inv_arm/cfg.json ./lambda/ArmErrorDetector/cfg_lambda.json
      ./group_setup.py associate-lambda ./master/cfg.json ./lambda/MasterBrain/cfg_lambda.json
      ./group_setup.py associate-lambda ./master/cfg.json ./lambda/MasterErrorDetector/cfg_lambda.json

      Note: You can see the details of each Lambda associated in the cfg.json files. Example:

        ...
        "lambda_functions": {
          "ArmErrorDetector": {
            "arn": "arn:aws:lambda:us-west-2:EXAMPLE_ACCT:function:ArmErrorDetector:mini",
            "arn_qualifier": "mini"
          }...
    9. Download and prep the servo software used by the Greengrass Devices
      ./servo_setup.py
    10. Instantiate the fully-formed Greengrass Groups with the following commands:
      ./group_setup.py create sort_arm ./arm/sort_arm/cfg.json --group-name sort_arm
      ./group_setup.py create inv_arm ./arm/inv_arm/cfg.json --group_name inv_arm
      ./group_setup.py create master ./master/cfg.json --group_name master
      ./group_setup.py deploy ./arm/sort_arm/cfg.json
      ./group_setup.py deploy ./arm/inv_arm/cfg.json
      ./group_setup.py deploy ./master/cfg.json

      Note: until cross-group discovery is improved the --group-name options above must be as written. The bridge.py Greengrass Device relies upon them

  5. Prep the Greengrass software

    1. Prepare each host for Greengrass
    2. Go here in the AWS console and download the greengrass-linux-armv7 distribution
    3. Perform the Installing the AWS Greengrass Core step
  6. Now copy the directories from the developer local aws-greengrass-mini-fulfillment repository to each of the three Raspberry Pi hosts. Specifically, all contents of:

    • ~/aws-greengrass-mini-fulfillment/groups/arm to sort_arm-pi$ ~/mini-fulfillment/groups/arm
    • ~/aws-greengrass-mini-fulfillment/groups/arm to inv_arm-pi$ ~/mini-fulfillment/groups/arm, and
    • ~/aws-greengrass-mini-fulfillment/groups/master to master-pi$ ~/mini-fulfillment/groups/master
  7. On the master host

    1. cd ~/mini-fulfillment/groups/master/
    2. pip install -r requirements.txt

      Note you might need to use sudo and it can take some time to install numpy

    3. chmod 755 cp_certs.sh servo_build.sh start_master.sh stop_master.sh
    4. Make the Dynamixel SDK by executing ./servo_build.sh
    5. Execute ./cp_certs.sh. This will copy the host's certs into the necessary GG Core location.
    6. As described in the Configure AWS Greengrass Core step, edit the configuration /greengrass/config/config.json as follows:
      {
         "coreThing": {
             "caPath": "root-ca.pem",
             "certPath": "master-core.pem",
             "keyPath": "master-core.prv",
             "thingArn": "arn:aws:iot:[AWS_REGION_HERE]:[AWS_ACCOUNT_ID]:thing/master-core",
             "iotHost": "[HOST_PREFIX_HERE].iot.[AWS_REGION_HERE].amazonaws.com",
             "ggHost": "greengrass.iot.[AWS_REGION_HERE].amazonaws.com",
             "keepAlive": 600
         },
         "runtime": {
             "cgroup": {
                 "useSystemd": "yes"
             }
         }
      }

      Note: determine the thingArn from the ~/mini-fulfillment/groups/master/cfg.json file on the host, determine the iotHost from the Settings in the IoT Console, and the ggHost AWS region will be the same as in the thingArn value.

  8. On the sort_arm host

    1. cd ~/mini-fulfillment/groups/arm/
    2. pip install -r requirements.txt

      Note you might need to use sudo

    3. chmod 755 cp_sort_arm_certs.sh servo_build.sh start_sort_arm.sh stop_arm.sh
    4. Make the Dynamixel SDK by executing ./servo_build.sh
    5. Execute ./cp_sort_arm_certs.sh. This will copy the host's certs into the necessary GG Core location.
    6. As described in the Configure AWS Greengrass Core step, edit the configuration /greengrass/config/config.json as follows:
      {
         "coreThing": {
             "caPath": "root-ca.pem",
             "certPath": "sort_arm-core.pem",
             "keyPath": "sort_arm-core.prv",
             "thingArn": "arn:aws:iot:[AWS_REGION_HERE]:[AWS_ACCOUNT_ID]:thing/sort_arm-core",
             "iotHost": "[HOST_PREFIX_HERE].iot.[AWS_REGION_HERE].amazonaws.com",
             "ggHost": "greengrass.iot.[AWS_REGION_HERE].amazonaws.com",
             "keepAlive": 600
         },
         "runtime": {
             "cgroup": {
                 "useSystemd": "yes"
             }
         }
      }

      Note: determine the thingArn from the ~/mini-fulfillment/groups/arm/sort_arm/cfg.json file on the host, determine the iotHost from the Settings in the IoT Console, and the ggHost AWS region will be the same as in the thingArn value.

  9. On the inv_arm host

    1. cd ~/mini-fulfillment/groups/arm/
    2. pip install -r requirements.txt

      Note you might need to use sudo

    3. chmod 755 cp_inv_arm_certs.sh servo_build.sh start_inv_arm.sh stop_arm.sh
    4. Make the Dynamixel SDK by executing ./servo_build.sh
    5. Execute ./cp_inv_arm_certs.sh. This will copy the host's certs into the necessary GG Core location.
    6. As described in the Configure AWS Greengrass Core step, edit the configuration /greengrass/config/config.json as follows:
      {
         "coreThing": {
             "caPath": "root-ca.pem",
             "certPath": "inv_arm-core.pem",
             "keyPath": "inv_arm-core.prv",
             "thingArn": "arn:aws:iot:[AWS_REGION_HERE]:[AWS_ACCOUNT_ID]:thing/inv_arm-core",
             "iotHost": "[HOST_PREFIX_HERE].iot.[AWS_REGION_HERE].amazonaws.com",
             "ggHost": "greengrass.iot.[AWS_REGION_HERE].amazonaws.com",
             "keepAlive": 600
         },
         "runtime": {
             "cgroup": {
                 "useSystemd": "yes"
             }
         }
      }

      Note: determine the thingArn from the ~/mini-fulfillment/groups/arm/inv_arm/cfg.json file on the host and determine the iotHost from the Settings in the IoT Console, and the ggHost AWS region will be the same as in the thingArn value.

  10. Using the operation instructions start the GG Cores and Devices in the following order:

    1. Start the master GG Core
    2. Start the sort_arm GG Core and the sort_arm GG Devices
    3. Start the inv_arm GG Core and the inv_arm GG Devices
    4. Start the master GG Devices

    ✅ at this point in time you should see the master host button box's white button light turn on.

  11. Use the physical green and red buttons to start and stop the demo, respectively.

Note: If you experience trouble, checkout the troubleshooting doc

Instantiation of Greengrass Groups is now complete

-=-=-=-=-