Permalink
Browse files

First pass

  • Loading branch information...
dzimine committed Feb 27, 2018
1 parent 2a05ddd commit c49ed79da602c499a10e450cd71a447c5c09e16c
Showing with 519 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +79 −0 README.md
  3. +40 −0 Vagrantfile
  4. +349 −0 greenfly.py
  5. +24 −0 group.yaml
  6. +4 −0 requirements.txt
  7. +20 −0 scripts/install.sh
@@ -0,0 +1,3 @@
certs/**
config/**
venv
@@ -1,5 +1,84 @@
# Boilerplate for AWS IoT Greengrass

A starter project to bring up (and clean-up!) AWS Greengrass setup for play and profit. If you followed the [GreenGrass Getting Started Guide](https://docs.aws.amazon.com/greengrass/latest/developerguide/gg-gs.html), 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)](https://github.com/awslabs/aws-iot-elf) and [aws-greengrass-group-setup](https://github.com/awslabs/aws-greengrass-group-setup).

## Pre-requisits

* A computer with Linux/MacOS, Python, git (dah!)
* [Vagrant](https://www.vagrantup.com/docs/installation/) with [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
* AWS CLI [installed](http://docs.aws.amazon.com/cli/latest/userguide/installing.html) and [configured](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html). Consider using [named profiles](https://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html).


## Set it Up

Clone the repo:

```
git clone https://github.com/dzimine/greenfly
cd greenfly
```

Create and activate a virtual environment, install the dependencies

```
virtualenv venv
source ~/dev/aws-iot-elf/venv/bin/activate
pip install -r requirements.txt
```

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 this sucks... I'll automate it later, meantime PR welcome.
## Play
1. Create GreenGrass Group definition in AWS
Fancy yourself with the group definitions in `group.yaml`, and run `greenfly`:
```
python greenfly.py create
```
When runs with no errors, it creates all greengrass group artefacts on AWS.
2. Provision VM with GreenGrass Core with Vagrant
```
vagrant up
```
3. Deploy Greengrass Group to the Core on the VM.
```
python greenfly.py deploy
```
4. Clean-up when done playing.
Remove the group definitions on AWS:
```
python greenfly.py remove
```
Ditch the Vagrant VM:
```
vagrant destroy
```
# Details
Coming... Stay tuned.
@@ -0,0 +1,40 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

hostname = ENV['HOSTNAME'] ? ENV['HOSTNAME'] : 'greengrass'
box = ENV['BOX'] ? ENV['BOX'] : 'ubuntu/xenial64'

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "greengrass" do |gg|
# Box details
gg.vm.box = "#{box}"
gg.vm.hostname = "#{hostname}"

# Box Specifications
gg.vm.provider :virtualbox do |vb|
vb.name = "#{hostname}"
vb.memory = 2048
vb.cpus = 2
end

# NFS-synced directory for pack development
# Change "/path/to/directory/on/host" to point to existing directory on your laptop/host and uncomment:
# config.vm.synced_folder "/path/to/directory/on/host", "/opt/stackstorm/packs", :nfs => true, :mount_options => ['nfsvers=3']

# Configure a private network
gg.vm.network :private_network, ip: "192.168.16.30"

# Public (bridged) network may come handy for external access to VM (e.g. sensor development)
# See https://www.vagrantup.com/docs/networking/public_network.html
# gg.vm.network "public_network", bridge: 'en0: Wi-Fi (AirPort)'

gg.vm.provision "shell" do |s|
s.path = "scripts/install.sh"
s.privileged = false
end
end

end
Oops, something went wrong.

0 comments on commit c49ed79

Please sign in to comment.