Skip to main content

AWS Greengrass file-based setup tool based on greengo by d

Project description

Boilerplate for AWS IoT Greengrass

Build Status Python 2.7 Python 3.6 PyPI version

Greengo: a starter project to bring up (and clean-up!) AWS Greengrass setup for play and profit. If you followed the GreenGrass Getting Started Guide, here you find it automated, as code.

Work In Progress !

Describe your Greengrass group in group.yaml, write Lambda functions and device clients, provision Greengrass Core in Vagrant VM, deploy, and clean up.

Inspired by aws-iot-elf (Extremely Low Friction) and aws-greengrass-group-setup.

Pre-requisits

Set it Up

Install greengo from PyPI:

$ pip install greengo

Manually [*] download GreenGrassCore binary and place it in the ./downloads directory. Sign in to the AWS Management Console, navigate to the AWS IoT console, and download the AWS Greengrass Core Software from [Software section](https://us-west-2.console.aws.amazon.com/iotv2/home?region=us-west-2#/ software/greengrass). Yeah, manual sucks... I will automate it later. Or, submit your PR!

Play

  1. Create GreenGrass Group definition in AWS

    Fancy yourself with the group definitions in group.yaml, and run greengo:

    $ greengo create
    

    When runs with no errors, it creates all greengrass group artefacts on AWS and places certificates and config.json for GreenGrass Core in ./certs and ./config for Vagrant to use in provisioning on next step.

  2. Provision VM with GreenGrass Core with Vagrant

    $ vagrant up
    
  3. Deploy Greengrass Group to the Core on the VM.

    $ greengo deploy
    
  4. Check that everything works - see the "Check" section below.

  5. Profit !

  6. Work on it: create, change or remove Lambda functions, subscriptions, resources, and then update Greengrass.

    $ greengo update
    

Apply your changes by deploying it again:

```
$ greengo deploy
```
  1. Clean-up when done playing.

    Remove the group definitions on AWS:

    $ greengo remove
    

    Ditch the Vagrant VM:

    $ vagrant destroy
    

NOTE: If you want to create a new group but keep the Greengrass Core in the same Vagrant VM, you must update it with newly generated certificates and config.json file before deploying the group, and also reset deployment by getting the deployments/group/group.json back to virgin.

To do it: login to the Greengrass Vagrant VM and run /vagrant/scripts/update_ggc.sh on the Vagrant VM.

Details

Check the deployment

How to be sure everything something works? Follow this:

  1. Create greengrass group in AWS IoT: greengo create.
  2. Prepare GGC on the VM: update certificates, reset group.json, restart the greengrassd.
  3. Deploy with greengo deploy. Check:
    • Check the deployment status, should be 'Success'
  4. Explore Greengrass Core on your vagrant VM.
    • Login to Vagrant VM. You should nkow Vagrant but for the off case: vagrant ssh.
    • Check the GGC logs runtime.log and python_runtime.log under /greengrass/ggc/var/log/system. Runtime log should have a line about starting your lambda, or an error why the funtion is not started. In many cases (like not enough memory for Lambda), the deployment is 'Success' but the function fails to start. The errors can only be seen in the runtime.log. If the function starts successfully, runtime.log will contain a message like
    [2018-03-31T08:48:40.57Z][INFO]-Starting worker arn:aws:lambda:us-west-2:0000000000:function:GreengrassHelloWorld:12
    
    • Find and check your own Lambda log under /greengrass/ggc/var/log/system.
    • Check the greengrassd process: ps aux | grep greengrassd. Depending on deployment you might have several processes.
  5. In AWS console, check the MQTT topic with IoT MQTT Test page:
    REGION=`aws configure get region`; open https://$REGION.console.aws.amazon.com/iot/home?region=$REGION#/test
    
    Subscribe to the topic (e.g., hello/world), see the messages sent by the Greengrass Lambda function.

When something goes wrong

At this time greengo is just a prototype, a work-in-progress. Therefore it's not if but when somethings throws out, leaving the setup in half-deployed, and you gotta pick up the pieces. Remember:

  • You are still not worse off doing this manually: you at least have all the ARN and Id of all resources to clean-up.
  • DON'T DELETE .gg/gg_state.json file: it contains references to everything you need to delete. Copy it somewhere and use the Id and Arn of created resources to clean up the pieces.
  • Do what it takes to roll forward - if you're close to successful deployment, or roll-back - to clean things up and start from scratch.

Please pay forward: PR a patch to whatever broke for you to prevent it from happening again.

Development

Clone the project, set up your environment, install dependencies and setup greengo CLI in dev mode:

$ git clone https://github.com/dzimine/greengo.git
$ cd greengo

# For python2:
$ virtualenv venv
$ . venv/bin/activate

# For python3
$ python3 -m venv .venv3
$ . .venv3/bin/activate

$ pip install -r requirements.txt

# Install greengo into the virtualenv
$ pip install -e .

Run the unit tests:

pytest -s tests/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gud-2.0.7.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

gud-2.0.7-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file gud-2.0.7.tar.gz.

File metadata

  • Download URL: gud-2.0.7.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/41.4.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.9

File hashes

Hashes for gud-2.0.7.tar.gz
Algorithm Hash digest
SHA256 a381368a1c6c21b42ec0d0e527716415ccfeab2b3aa8bf69565da70b60bec55d
MD5 bce3d45fc4090b5c7927e775740944e9
BLAKE2b-256 23c7e7b8566edf2dabd96bc085451c9f70bbbcb6b68a94d62efad766a243af42

See more details on using hashes here.

File details

Details for the file gud-2.0.7-py3-none-any.whl.

File metadata

  • Download URL: gud-2.0.7-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/41.4.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.9

File hashes

Hashes for gud-2.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a4e9e869bacaef06ed87191a217132aa3d287ce5e92abcfd3c7b8df16c51708c
MD5 bb233b6359650a84b157095d6e128675
BLAKE2b-256 ffe9460be8d348e47be9c1b4ab27e288febeb1042a81a5ae4cfb8ede8b8805b9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page