Getting started with AWS IoT Greengrass - AWS IoT Greengrass

AWS IoT Greengrass Version 1 entered the extended life phase on June 30, 2023. For more information, see the AWS IoT Greengrass V1 maintenance policy. After this date, AWS IoT Greengrass V1 won't release updates that provide features, enhancements, bug fixes, or security patches. Devices that run on AWS IoT Greengrass V1 won't be disrupted and will continue to operate and to connect to the cloud. We strongly recommend that you migrate to AWS IoT Greengrass Version 2, which adds significant new features and support for additional platforms.

Getting started with AWS IoT Greengrass

This Getting Started tutorial includes several modules designed to show you AWS IoT Greengrass basics and help you get started using AWS IoT Greengrass. This tutorial covers fundamental concepts, such as:

  • Configuring AWS IoT Greengrass cores and groups.

  • The deployment process for running AWS Lambda functions at the edge.

  • Connecting AWS IoT devices, called client devices, to the AWS IoT Greengrass core.

  • Creating subscriptions to allow MQTT communication between local Lambda functions, client devices, and AWS IoT.

Choose how to get started with AWS IoT Greengrass

You can choose how to use this tutorial to set up your core device:

  • Run Greengrass device setup on your core device, which takes you from installing AWS IoT Greengrass dependencies to testing a Hello World Lambda function in minutes. This script reproduces the steps in Module 1 through Module 3-1.

     

     - or -

     

  • Walk through the steps in Module 1 through Module 3-1 to examine Greengrass requirements and processes more closely. These steps set up your core device, create and configure a Greengrass group that contains a Hello World Lambda function, and deploy your Greengrass group. Typically, this takes an hour or two to complete.


                Getting Started modules
Quick Start

Greengrass device setup configures your core device and Greengrass resources. The script:

  • Installs AWS IoT Greengrass dependencies.

  • Downloads the root CA certificate and core device certificate and keys.

  • Downloads, installs, and configures the AWS IoT Greengrass Core software on your device.

  • Starts the Greengrass daemon process on the core device.

  • Creates or updates the Greengrass service role, if needed.

  • Creates a Greengrass group and Greengrass core.

  • (Optional) Creates a Hello World Lambda function, subscription, and local logging configuration.

  • (Optional) Deploys the Greengrass group.

Modules 1 and 2

Module 1 and Module 2 describe how to set up your environment. (Or, use Greengrass device setup to run these modules for you.)

  • Configure your core device for Greengrass.

  • Run the dependency checker script.

  • Create a Greengrass group and Greengrass core.

  • Download and install the latest AWS IoT Greengrass Core software from a tar.gz file.

  • Start the Greengrass daemon process on the core.

Note

AWS IoT Greengrass also provides other options for installing the AWS IoT Greengrass Core software, including apt installations on supported Debian platforms. For more information, see Install the AWS IoT Greengrass Core software.

Modules 3-1 and 3-2

Module 3-1 and Module 3-2 describe how to use local Lambda functions. (Or, use Greengrass device setup to run Module 3-1 for you.)

  • Create Hello World Lambda functions in AWS Lambda.

  • Add Lambda functions to your Greengrass group.

  • Create subscriptions that allow MQTT communication between the Lambda functions and AWS IoT.

  • Configure local logging for Greengrass system components and Lambda functions.

  • Deploy a Greengrass group that contains your Lambda functions and subscriptions.

  • Send messages from local Lambda functions to AWS IoT.

  • Invoke local Lambda functions from AWS IoT.

  • Test on-demand and long-lived functions.

Modules 4 and 5

Module 4 shows how client devices connect to the core and communicate with each other.

Module 5 shows how client devices can use shadows to control state.

  • Register and provision AWS IoT devices (represented by command-line terminals).

  • Install the AWS IoT Device SDK for Python. This is used by client devices to discover the Greengrass core.

  • Add the client devices to your Greengrass group.

  • Create subscriptions that allow MQTT communication.

  • Deploy a Greengrass group that contains your client devices.

  • Test device-to-device communication.

  • Test shadow state updates.

Module 6

Module 6 shows you how Lambda functions can access the AWS Cloud.

  • Create a Greengrass group role that allows access to Amazon DynamoDB resources.

  • Add a Lambda function to your Greengrass group. This function uses the AWS SDK for Python to interact with DynamoDB.

  • Create subscriptions that allow MQTT communication.

  • Test the interaction with DynamoDB.

Module 7

Module 7 shows you how to configure a simulated hardware security module (HSM) for use with a Greengrass core.

Important

This advanced module is provided only for experimentation and initial testing. It is not for production use of any kind.

  • Install and configure a software-based HSM and private key.

  • Configure the Greengrass core to use hardware security.

  • Test the hardware security configuration.

Requirements

To complete this tutorial, you need the following:

  • A Mac, Windows PC, or UNIX-like system.

  • An AWS account. If you don't have one, see Create an AWS account.

  • The use of an AWS Region that supports AWS IoT Greengrass. For the list of supported regions for AWS IoT Greengrass, see AWS endpoints and quotas in the AWS General Reference.

    Note

    Make a note of your AWS Region and make sure that it is consistently used throughout this tutorial. If you switch your AWS Region during the tutorial, you might experience problems completing the steps.

  • A Raspberry Pi 4 Model B, or Raspberry Pi 3 Model B/B+, with a 8 GB microSD card, or an Amazon EC2 instance. Because AWS IoT Greengrass should ideally be used with physical hardware, we recommend that you use a Raspberry Pi.

    Note

    Run the following command to get the model of your Raspberry Pi:

    cat /proc/cpuinfo

    Near the bottom of the listing, make a note of the value of the Revision attribute and then consult the Which Pi have I got? table. For example, if the value of Revision is a02082, the table shows the Pi is a 3 Model B.

    Run the following command to determine the architecture of your Raspberry Pi:

    uname -m

    For this tutorial, the result should be greater than or equal to armv71.

  • Basic familiarity with Python.

Although this tutorial is intended to run AWS IoT Greengrass on a Raspberry Pi, AWS IoT Greengrass also supports other platforms. For more information, see Supported platforms and requirements.

Create an AWS account

If you don't have an AWS account, follow these steps to create and activate an AWS account:

Sign up for an AWS account

If you do not have an AWS account, complete the following steps to create one.

To sign up for an AWS account
  1. Open https://portal.aws.amazon.com/billing/signup.

  2. Follow the online instructions.

    Part of the sign-up procedure involves receiving a phone call and entering a verification code on the phone keypad.

    When you sign up for an AWS account, an AWS account root user is created. The root user has access to all AWS services and resources in the account. As a security best practice, assign administrative access to an administrative user, and use only the root user to perform tasks that require root user access.

AWS sends you a confirmation email after the sign-up process is complete. At any time, you can view your current account activity and manage your account by going to https://aws.amazon.com/ and choosing My Account.

Create an administrative user

After you sign up for an AWS account, secure your AWS account root user, enable AWS IAM Identity Center, and create an administrative user so that you don't use the root user for everyday tasks.

Secure your AWS account root user
  1. Sign in to the AWS Management Console as the account owner by choosing Root user and entering your AWS account email address. On the next page, enter your password.

    For help signing in by using root user, see Signing in as the root user in the AWS Sign-In User Guide.

  2. Turn on multi-factor authentication (MFA) for your root user.

    For instructions, see Enable a virtual MFA device for your AWS account root user (console) in the IAM User Guide.

Create an administrative user
  1. Enable IAM Identity Center.

    For instructions, see Enabling AWS IAM Identity Center in the AWS IAM Identity Center User Guide.

  2. In IAM Identity Center, grant administrative access to an administrative user.

    For a tutorial about using the IAM Identity Center directory as your identity source, see Configure user access with the default IAM Identity Center directory in the AWS IAM Identity Center User Guide.

Sign in as the administrative user
  • To sign in with your IAM Identity Center user, use the sign-in URL that was sent to your email address when you created the IAM Identity Center user.

    For help signing in using an IAM Identity Center user, see Signing in to the AWS access portal in the AWS Sign-In User Guide.

Important

For this tutorial, we assume that your IAM user account has administrator access permissions.