Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Definition
2.1.
Amazon IoT Greengrass Core software
2.2.
Amazon IoT Greengrass Core software versions
2.3.
Supported Platforms for Amazon IoT Greengrass
3.
Installation of the Software
4.
Configure the Amazon IoT Greengrass core
5.
Deploy Amazon IoT Greengrass Groups to an Amazon IoT Greengrass Core
6.
Lambda functions
6.1.
Deploying Groups from the Amazon IoT Console
6.2.
Reset Deployments from the Amazon IoT Console
6.3.
Deploying Groups with the help of Amazon IoT Greengrass API
6.4.
Reset Deployments with the help of Amazon IoT Greengrass API
7.
Create Bulk Deployments for Groups
7.1.
Amazon IoT Greengrass Core SDK
8.
Controlling the Execution of Greengrass Lambda Functions by Using Group-Specific Configuration
8.1.
Group-specific configuration settings
9.
Running Amazon IoT Greengrass in a Docker Container
10.
Configuration of local resource access using the Amazon command-line interface
11.
Configuration of Local Resource Access Using the Amazon Web Services Management Console
12.
Frequently Asked Questions
13.
Conclusion
Last Updated: Mar 27, 2024
Easy

Amazon IoT Greengrass

Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

Have you ever wondered about Amazon IoT Greengrass? Or try to study it in detail?

If not, then this article is for you where your doubts about what Amazon IoT Greengrass is, How to install the software, what the configurations are, and many more.

Let's start with "What is Amazon IoT Greengrass"?

Definition

Amazon IoT Greengrass allows you to collect and analyze the data closer to the source of information and communicate securely with each other on local networks by providing cloud capabilities to local devices.

 

The architecture of Amazon IoT Greengrass: 

AWS IoT Greengrass | AWS Architecture Blog

Amazon IoT Greengrass provides us with cloud-based management of application logic that runs on devices. The main use of Amazon IoT Greengrass is that devices securely communicate on a local network and exchange messages without connecting to the cloud. 

Amazon IoT Greengrass provides us with secure, over-the-air updates of Lambda functions.

 

Amazon IoT Greengrass consists of:

Cloud service

Software distributions

Features

  • Lambda runtime
  • Shadows implementation

Amazon IoT Greengrass Core software

Secure connections between devices and the Amazon Web Services Cloud using device authorization and authentication.

  • Controlled access to local devices over MQTT and volume resources.
  • Greengrass core device can be discovered by Automatic IP address detection.
  • Deployment and the local running of connectors and Lambda functions.

Amazon IoT Greengrass Core software versions

There are several options for installing the Amazon IoT Greengrass Core Software. Some of the versions of Amazon IoT Greengrass are:

  • 1.11.6
  • 1.11.5
  • 1.11.3
  • 1.11.4
  • 1.11.1
  • 1.11.0

Supported Platforms for Amazon IoT Greengrass

  • Architecture: Armv7l
  • Architecture: Armv6l
  • Architecture: Armv8 (AArch64)
  • Architecture: x86_64
  • Linux kernel version:
Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Installation of the Software

Amazon IoT Greengrass provides us with several options for installing the Amazon IoT Greengrass Core software:

1). Download and extract a tar.gz file.

Choose the Amazon IoT Greengrass Core software for your platform to download as a tar.gz file and extract it on your device. You can download recent versions of the software.

2). Install from an APT repository.

The APT repository provided by Amazon IoT Greengrass includes the following packages:

  • aws-iot-greengrass-core. Installs the Amazon IoT Greengrass Core software.
  • aws-iot-greengrass-keyring. The GnuPG (GPG) keys are installed to sign the Amazon IoT Greengrass package repository.

3). Run the Greengrass Device Setup script.

Run Greengrass device setup to configure your device, install the latest Amazon IoT Greengrass Core software version, and deploy any Lambda function in minutes.

See this, Amazon Hirepro

Configure the Amazon IoT Greengrass core

Amazon IoT Greengrass is an Amazon IoT device that acts as a hub in edge environments. The core device has run Amazon IoT Greengrass core software, enabling it to manage local processes for Greengrass groups, such as shadow sync, communication, and token exchange.

Amazon IoT Greengrass Core Configuration File
A configuration file for the Amazon IoT Greengrass Core software called "config.json." The location of this is in the /greengrass-root/config directory.

Here "greengrass-root" represents the path where the Amazon IoT Greengrass Core software is installed on your device. 

Deploy Amazon IoT Greengrass Groups to an Amazon IoT Greengrass Core

Groups are used to control the entities in the environment. It can also control how the entities interact with Amazon Web Services Cloud and each other. 

For example, only the Lambda functions in the group are deployed for running locally, and only the devices in the group are allowed to communicate using the local MQTT server.

 

As we read above, Amazon IoT Greengrass core software has been run by the core; the group must also include a core. The core here acts as an edge gateway and provides Amazon IoT Core capabilities in the edge environment. 

The following entities can be added to a group:

  • Connectors
  • Devices
  • Loggers

Lambda functions

Manage your Greengrass group in the Amazon Web Services Cloud, and after this, deploy it to a core. Group configuration is copied to the "group.json" file by the deployment on the core device. The location of this file is in greengrass-root/ggc/deployments/group.

Deploying Groups from the Amazon IoT Console

Deployments can be managed from the group's configuration page, and you can deploy a group in the Amazon IoT console.

To deploy the current version of the group

  • From Actions, choose Deploy.

To view the deployment history of the group.

A group's deployment history includes the date and time, and status of each deployment attempt.

  1. From the navigation pane, choose Deployments.
  2. Select the deployment row to see more information about deployment, including error messages.

Reset Deployments from the Amazon IoT Console

You can reset group deployments from the group configuration page in the Amazon IoT console.

  1. Choose Greengrass, Classic (V1), and Groups in the Amazon IoT console navigation pane.
  2. Choose the target group.
  3. From Actions, choose Reset Deployments.

Deploying Groups with the help of Amazon IoT Greengrass API

The Amazon IoT Greengrass API provides us with some actions to deploy Amazon IoT Greengrass groups and manage these group deployments. You can call these actions from the Amazon Command Line Interface(CLI), Amazon IoT Greengrass API, or Amazon SDK.

Reset Deployments with the help of Amazon IoT Greengrass API

To reset deployments, you can use the ResetDeployments action in the Amazon CLI, Amazon IoT Greengrass API, or Amazon SDK. The examples in this topic use the CLI(Command Line Interface).

aws greengrass reset-deployments --group-id GroupId [--force]

Arguments for the reset-deployments CLI command with their use:

–group-id

The group iD is used in the list-groups command to get this value.

–force

Optional. This parameter is used if the group's core device has been lost, stolen, or may be destroyed. This option is rather good to use as it causes the reset deployment process to report success after all information(deployed) in the cloud has been cleaned up without waiting for a core device to respond.

Create Bulk Deployments for Groups

You can use simple API calls to deploy large numbers of Greengrass groups at once. These deployments are triggered with an adaptive rate with a fixed upper limit.

Step 1: Create and upload the bulk deployment input file

Step 2: Create and configure an IAM execution role

Step 3: Allow your execution role access to your S3 Bucket

Step 4: Deploy the groups

Step 5: Test the deployment

Run Lambda Functions on the Amazon IoT Greengrass Core

Lambda functions deployed to an Amazon IoT Greengrass core run in the core's local Lambda runtime. AWS IoT Greengrass has provided a containerized Lambda runtime environment for the user-defined code you author in Amazon Lambda.

For example, Greengrass Lambda functions can filter device data before transmitting the data to the cloud. 

 

You have the power to configure parameters that determine how the Lambda functions run, isolation, including permissions, and memory limits.

Amazon IoT Greengrass Core SDK

  • Interact with the local shadow service.
  • Access secret resources.
  • Exchange MQTT messages with Amazon IoT Core.

Controlling the Execution of Greengrass Lambda Functions by Using Group-Specific Configuration

You have the authority to configure how the Lambda function behaves when it runs in a Greengrass group.

Group-specific configuration settings

The following group-specific configuration settings for Greengrass Lambda functions are:

  • UID (number)
  • Run as
  • GID (number)
  • Containerization
  • Lifecycle
  • Memory limit
  • Timeout
  • Read access to /sys directory
  • Input payload data type
  • Environment variables
  • Resource access policies

Running Amazon IoT Greengrass in a Docker Container

This topic describes downloading the Amazon IoT Greengrass Docker image from Amazon ECR and running it on a Windows, macOS, or Linux (x86_64) platform.

Step 1: Get the Amazon IoT Greengrass container image from Amazon ECR

Step 2: Create and configure the Greengrass group and core

Step 3: Run Amazon IoT Greengrass locally

Step 4: Configure "No container" containerization for the Greengrass group

Step 5: Deploy Lambda functions to the Amazon IoT Greengrass Docker container

Step 6: (Optional) Deploy devices that interact with Greengrass running in the Docker container

Configuration of local resource access using the Amazon command-line interface

You must add a resource definition to the group definition to use a local resource deployed to your Greengrass core device. The group definition must also contain a Lambda function definition in which you grant access permissions for local resources to your Lambda functions. 

This configuration feature is available for Amazon IoT Greengrass Core v1.3 and other versions.

  • Create local resources
  • Create the Greengrass function
  • Add the Lambda function to the group
  • Troubleshooting

Configuration of Local Resource Access Using the Amazon Web Services Management Console

You can configure Lambda functions to access local resources on the host Greengrass core device securely. Local resources refer to buses and peripherals that are physically present on the host or file system volumes on the host OS. 

This subheading describes how to use the Amazon Web Services Management Console to configure access to local resources on an Amazon IoT Greengrass core device.

Step 1: Create a Lambda function deployment package

Step 2: Create and publish a Lambda function

Step 3: Add the Lambda function to the Greengrass group

Step 4: Add a local resource to the Greengrass group

Step 5: Add subscriptions to the Greengrass group

Step 6: Deploy the Amazon IoT Greengrass group

Check out this article - Components Of IOT

Frequently Asked Questions

  1. What do you mean by Docker Container?
    • A Docker container image is a lightweight executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries, and settings.
  2. What is an MQTT message?
    • The MQTT packet or message format consists of a 2-byte fixed header (always present) + Variable-header (not always present)+ payload (not always present).

Conclusion

Amazon IoT Greengrass allows you to collect and analyze the data closer to the source of information and communicate securely with each other on local networks by providing cloud capabilities to local devices.

This article has covered some important AWS IoT Greengrass console usage.

Click here to read out these amazing articles AWS Certified and AWS interview questions.

If you wonder how to prepare data structures and algorithms to do well in your programming interviews, here is your ultimate guide for practicing and testing your problem-solving skills on Coding Ninjas Studio

 

Happing Coding!!!

 

Next article
AWS IoT 1-Click
Live masterclass