Package: gud
Boilerplate for AWS IoT GreengrassGreengo: a starter project to bring up (and clean-up!) AWS Greengrass setup for play and profit. If you followed theGreenGrass Getting Started Guide, here you find it automated, as code.Work In Progress !Describe your Greengrass group ingroup.yaml, write Lambda functions and device clients, provision Greengrass Core in Vagrant VM, deploy, and clean up.Inspired byaws-iot-elf (Extremely Low Friction)andaws-greengrass-group-setup.Pre-requisitsA computer with Linux/MacOS, Python, git (dah!)VagrantwithVirtualBoxAWS CLIinstalledandconfigured. Consider usingnamed profiles.Set it UpInstallgreengofrom PyPI:$ pip install greengoManually [*] download GreenGrassCore binary and place it in the./downloadsdirectory.
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!PlayCreate GreenGrass Group definition in AWSFancy yourself with the group definitions ingroup.yaml, and rungreengo:$ greengo createWhen runs with no errors, it creates all greengrass group artefacts on AWS
and places certificates andconfig.jsonfor GreenGrass Core in./certsand./configfor Vagrant to use in provisioning on next step.Provision VM with GreenGrass Core with Vagrant$ vagrant upDeploy Greengrass Group to the Core on the VM.$ greengo deployCheck that everything works - see the"Check" sectionbelow.Profit !Work on it: create, change or remove Lambda functions, subscriptions, resources, and then update Greengrass.$ greengo updateApply your changes by deploying it again:```
$ greengo deploy
```Clean-up when done playing.Remove the group definitions on AWS:$ greengo removeDitch the Vagrant VM:$ vagrant destroyNOTE: 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 andconfig.jsonfile
before deploying the group, and also reset deployment by getting
thedeployments/group/group.jsonback to virgin.To do it: login to the Greengrass Vagrant VM and run/vagrant/scripts/update_ggc.shon the Vagrant VM.DetailsCheck the deploymentHow to be sureeverythingsomething works? Follow this:Create greengrass group in AWS IoT:greengo create.Prepare GGC on the VM: update certificates, resetgroup.json, restart thegreengrassd.Deploy withgreengo deploy. Check:Check the deployment status, should be 'Success'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 logsruntime.logandpython_runtime.logunder/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 theruntime.log.
If the function starts successfully,runtime.logwill contain a message like[2018-03-31T08:48:40.57Z][INFO]-Starting worker arn:aws:lambda:us-west-2:0000000000:function:GreengrassHelloWorld:12Find 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.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#/testSubscribe to the topic (e.g.,hello/world), see the messages sent by the Greengrass Lambda function.When something goes wrongAt this timegreengois just a prototype, a work-in-progress. Therefore it's notifbutwhensomethings 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 theARNandIdof all resources to clean-up.DON'T DELETE.gg/gg_state.jsonfile: it contains references to everything you need to delete. Copy it somewhere and use theIdandArnof 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.DevelopmentClone the project, set up your environment, install dependencies and setupgreengoCLI 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/