For some applications, it makes sense to keep processing on premises. AWS Greengrass provides that option for IoT...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
and similar cloud workloads.
AWS Greengrass became generally available in June 2017. The Lambda-like service provides a compute environment for on-premises hardware to users who could not move all workloads to the cloud for performance, cost or legal reasons. For example, internet of things devices often experience this type of cloud isolation, especially in areas without reliable internet connections.
The AWS Greengrass service incorporates a shadow device -- like most IoT operations -- and integrates directly with the Message Queuing Telemetry Transport (MQTT) protocol for communication among devices. But Greengrass is neither a Lambda alternative nor a way to develop or run Lambda functions locally. Greengrass only operates on Python 2.7 and does not support Node.js; there is also no way to run a Lambda call directly -- let alone execute the request on Greengrass IoT-compatible devices.
However, Greengrass runs commands on IoT devices that easily connect to other Amazon services. It provides a Lambda-like interface, which includes methods to securely integrate AWS credentials onto IoT devices. The Greengrass IoT platform uses Secure Sockets Layer certificates and sends temporary credentials via AWS Identity and Access Management to each service. Greengrass should feel like a welcome improvement for IoT users, bringing some AWS features to devices with spotty or nonexistent internet.
Get started with Greengrass, IoT
Raspberry Pi, one of the most popular IoT devices, integrates well with AWS Greengrass; Amazon has a step-by-step guide on how to set up a hello-world project to connect Raspberry Pi to Greengrass. And because Greengrass supports event handlers, the hello-world example shows developers how to ignore that handler.
But what if you wanted to use the event-driven nature of AWS Lambda? Greengrass doesn't support attachment to triggers, which means developers cannot subscribe to a DynamoDB Stream to run local Greengrass functions when changes are made to a DynamoDB table. But they can execute functions on demand, similar to Lambda's invoke function. While there is no way to directly invoke a Greengrass function, developers can set up a subscription to an AWS IoT thing to call the Greengrass function when it executes. For example, developers can set up an AWS IoT Button so that, when they press it, that triggers a local Greengrass function to run -- instead of using a cloud-based Lambda function.
AWS Greengrass pushes the right buttons
Let's use an IoT doorbell as an example. When someone pushes the AWS IoT Button, Raspberry Pi automatically takes a photo of that person and sends it to your phone. This would not work if devices lost an internet connection. With Greengrass, the local Raspberry Pi is notified on each button press; it then executes the local function and performs another action -- if it is unable to send the SMS message because of connectivity issues.
To connect an AWS IoT Button to a local Lambda function, connect the button to your IoT account. Next, choose Devices and Add your first device. Then, choose Select an IoT Thing. Find, and select the iotbutton_ that corresponds to the button in your account. Then, select Finish to set up the subscription.
Under Subscriptions, choose Add Subscription. Under Select a Source, choose Select, then choose Devices and select your newly added IoT Button.
Next, go to Select a Target, and choose Lambda to pick the Lambda function that corresponds with the button press. Deploy this update like you would any other Greengrass IoT deployment. The next time the button is pressed, it will trigger a Greengrass Lambda function -- instead of a remote Lambda function.
It's also possible to have an IoT Button trigger multiple events, such as a remote Lambda function call and a local Greengrass Lambda function -- or even multiple Lambda functions. This can be a helpful way to introduce Greengrass to IoT developers using the IoT Button.
In this example, the Lambda function also could trigger code to take a quick photo via the camera and send it to your phone.
Build a Greengrass, IoT bridge
Greengrass is a bridge for IoT users who want to run code locally but also develop code similarly to how they would with AWS Lambda. It doesn't have the same triggers, so developers might be more inclined to use Lambda when it's available. Additionally, it won't help IT teams develop local versions of products that will run on Lambda, and there's no direct comparison with it in the cloud.
The Greengrass service is a first attempt to bring AWS compute capabilities to the IoT world and integrate tightly with MQTT and IoT. It provides its own set of complications and challenges and is currently very single-purpose by design. If Amazon makes it more of a general-purpose service, developers will be able to build and execute Lambda-style functions on both the AWS cloud and local devices seamlessly. Until that day arrives, however, developers will need to rely on third-party tools for local development and Lambda function tests.
Don't use the AWS IoT Button for critical tasks
Greengrass, IoT possibilities expand with AWS development
AWS functionality expands with Greengrass