Getting started with Amazon IoT Greengrass - Amazon IoT Greengrass
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Amazon IoT Greengrass Version 1 entered the extended life phase on June 30, 2023. For more information, see the Amazon IoT Greengrass V1 maintenance policy. After this date, Amazon IoT Greengrass V1 won't release updates that provide features, enhancements, bug fixes, or security patches. Devices that run on Amazon 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 Amazon IoT Greengrass Version 2, which adds significant new features and support for additional platforms.

Getting started with Amazon IoT Greengrass

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

  • Configuring Amazon IoT Greengrass cores and groups.

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

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

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

Choose how to get started with Amazon 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 Amazon 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 Amazon IoT Greengrass dependencies.

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

  • Downloads, installs, and configures the Amazon 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 Amazon IoT Greengrass Core software from a tar.gz file.

  • Start the Greengrass daemon process on the core.

Note

Amazon IoT Greengrass also provides other options for installing the Amazon IoT Greengrass Core software, including apt installations on supported Debian platforms. For more information, see Install the Amazon 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 Amazon Lambda.

  • Add Lambda functions to your Greengrass group.

  • Create subscriptions that allow MQTT communication between the Lambda functions and Amazon 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 Amazon IoT.

  • Invoke local Lambda functions from Amazon 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 Amazon IoT devices (represented by command-line terminals).

  • Install the Amazon 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 Amazon Web Services 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 Amazon 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 Amazon Web Services account. If you don't have one, see Create an Amazon Web Services account.

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

    Note

    Make a note of your Amazon Web Services Region and make sure that it is consistently used throughout this tutorial. If you switch your Amazon Web Services 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 Amazon 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 Amazon IoT Greengrass on a Raspberry Pi, Amazon IoT Greengrass also supports other platforms. For more information, see Supported platforms and requirements.

Create an Amazon Web Services account

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

Sign up for an Amazon Web Services account

If you do not have an Amazon Web Services account, use the following procedure to create one.

To sign up for Amazon Web Services
  1. Open http://www.amazonaws.cn/ and choose Sign Up.

  2. Follow the on-screen instructions.

Amazon 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 http://www.amazonaws.cn/ and choosing My Account.

Secure IAM users

After you sign up for an Amazon Web Services account, safeguard your administrative user by turning on multi-factor authentication (MFA). For instructions, see Enable a virtual MFA device for an IAM user (console) in the IAM User Guide.

To give other users access to your Amazon Web Services account resources, create IAM users. To secure your IAM users, turn on MFA and only give the IAM users the permissions needed to perform their tasks.

For more information about creating and securing IAM users, see the following topics in the IAM User Guide:

Important

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