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.
- From the navigation pane, choose Deployments.
- 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.
- Choose Greengrass, Classic (V1), and Groups in the Amazon IoT console navigation pane.
- Choose the target group.
- 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
-
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.
-
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!!!