Example local Lambda functions that can be used with AWS Greengrass and the AWS Greengrass Provisioner. This repo contains the functions and the deployment configurations to launch those functions in different configurations.
2020-01-27 - Minor changes to the role naming scheme may cause issues with existing deployments. If you are experiencing issues with permissions you can either switch to the new naming scheme (e.g. Greengrass_CoreRole
, Greengrass_ServiceRole
, and Greengrass_LambdaRole
) or you can update the deployments.defaults.conf file to use the older names.
Step 1: Clone this repo
Step 2: Read the provisioner command-line examples
Check out the Cloud Device Driver framework. It is a framework that simplifies writing Greengrass Lambda functions in Java. You can look at the code as well.
-
Python
- BenchmarkPython - a naive benchmark that creates a pinned function that sends messages to itself
- HTTPPython - sends HTTP requests from the core to any address (local network or otherwise), triggered by MQTT messages from the cloud
- HelloWorldPython3 - Hello, World in Python 3
- HelloWorldPythonWithCloudFormation - Hello, World in Python with a CloudFormation template that demonstrates how to build republish rules that the provisioner can launch automatically
- LiFXPython - control LiFX bulbs
- SocketServerPython - an example of how to listen on a socket in Python and relay the inbound TCP messages to the cloud via MQTT
- RaspberryPiGpioPython3 - Event driven GPIO handler for the Raspberry Pi (no polling)
- LatencyTesterPython3 - Sends ping requests to a fixed list of hosts and publishes the round trip ICMP ping time via MQTT
- CloudWatchMetricHandlerPython3 - Sends latency information to AWS as CloudWatch Metric values (used with LatencyTesterPython3)
- SecretsManagerPython3 - Retrieves a secret from Secrets Manager and publishes the value on a topic for testing purposes
- MqttClientPython3 - Connects to an MQTT broker as a client and relays messages from that broker to Greengrass
-
NodeJS
- HelloWorldNode - Hello, World in Node
- HTTPNode - sends HTTP requests from the core to any address (local network or otherwise), triggered by MQTT messages from the cloud
- WebServerNode - an example of how to create an Express web server in a pinned Lambda function
-
Java with Cloud Device Driver framework
- CDDSkeletonJava - shows how the Java Cloud Device Driver framework can be used
- CDDDMIJava - relays Desktop Management Interface (DMI) information to the cloud when requested via MQTT
- CDDBenchmarkJava - a naive Java benchmark that creates a pinned function that sends messages to itself
- CDDSenseHatJava - shows how to control a SenseHat display on a Raspberry Pi
- CDDDockerJava - shows how to control Docker with Greengrass
- CDDLatencyDashboard - a Vaadin-based dashboard to show latency information (used with LatencyTesterPython3)
- CDDMdnsServiceResolverJava - resolves mDNS service discovery broadcasts and publishes the discovery information to other functions
-
C
- ARM32SampleC - Hello World in C for ARM32 architectures
- X86_64SampleC - Hello World in C for X86_64 architectures
-
Greengrass Provisioner functionality examples
- Reusing functions from other groups (benchmark example) - shows how to reuse existing functions in the Greengrass Provisioner by using the tilde
~
wildcard - Launching an nginx proxy on ARM Greengrass cores with the Greengrass Docker connector - ARM only! shows how to use the Greengrass Docker connector in a deployment to launch nginx
- Launching Wordress on X86 Greengrass cores with the Greengrass Docker connector - X86 only! shows how to use the Greengrass Docker connector in a deployment to launch Wordpress
- Sharing files between two functions in Python 3 - shows how to share a file between two functions through the host. Each function randomly writes a value to a file that the other function can read, then the other function picks up the value, publishes it to the core, and deletes the shared file so it can be created again.
- Reusing functions from other groups (benchmark example) - shows how to reuse existing functions in the Greengrass Provisioner by using the tilde
This sample code is made available under a modified MIT license. See the LICENSE file.