Install the Amazon IoT Greengrass Core software (CLI) - 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).

Install the Amazon IoT Greengrass Core software (CLI)

To install and configure the Amazon IoT Greengrass Core software
  1. On your Greengrass core device, run the following command to switch to the home directory.

    Linux or Unix
    cd ~
    Windows Command Prompt (CMD)
    cd %USERPROFILE%
    PowerShell
    cd ~
  2. On your core device, download the Amazon IoT Greengrass Core software to a file named greengrass-nucleus-latest.zip.

    Linux or Unix
    curl -s https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip > greengrass-nucleus-latest.zip
    Windows Command Prompt (CMD)
    curl -s https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip > greengrass-nucleus-latest.zip
    PowerShell
    iwr -Uri https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip -OutFile greengrass-nucleus-latest.zip

    By downloading this software, you agree to the Greengrass Core Software License Agreement.

  3. Unzip the Amazon IoT Greengrass Core software to a folder on your device. Replace GreengrassInstaller with the folder that you want to use.

    Linux or Unix
    unzip greengrass-nucleus-latest.zip -d GreengrassInstaller && rm greengrass-nucleus-latest.zip
    Windows Command Prompt (CMD)
    mkdir GreengrassInstaller && tar -xf greengrass-nucleus-latest.zip -C GreengrassInstaller && del greengrass-nucleus-latest.zip
    PowerShell
    Expand-Archive -Path greengrass-nucleus-latest.zip -DestinationPath .\\GreengrassInstaller rm greengrass-nucleus-latest.zip
  4. Run the following command to launch the Amazon IoT Greengrass Core software installer. This command does the following:

    • Create the Amazon resources that the core device requires to operate.

    • Set up the Amazon IoT Greengrass Core software as a system service that runs at boot. On Linux devices, this requires the Systemd init system.

      Important

      On Windows core devices, you must set up the Amazon IoT Greengrass Core software as a system service.

    • Deploy the Amazon IoT Greengrass CLI component, which is a command-line tool that enables you to develop custom Greengrass components on the core device.

    • Specify to use the ggc_user system user to run software components on the core device. On Linux devices, this command also specifies to use the ggc_group system group, and the installer creates the system user and group for you.

    Replace argument values in your command as follows.

    1. /greengrass/v2 or C:\greengrass\v2: The path to the root folder to use to install the Amazon IoT Greengrass Core software.

    2. GreengrassInstaller. The path to the folder where you unpacked the Amazon IoT Greengrass Core software installer.

    3. region. The Amazon Web Services Region in which to find or create resources.

    4. MyGreengrassCore. The name of the Amazon IoT thing for your Greengrass core device. If the thing doesn't exist, the installer creates it. The installer downloads the certificates to authenticate as the Amazon IoT thing. For more information, see Device authentication and authorization for Amazon IoT Greengrass.

      Note

      The thing name can't contain colon (:) characters.

    5. MyGreengrassCoreGroup. The name of Amazon IoT thing group for your Greengrass core device. If the thing group doesn't exist, the installer creates it and adds the thing to it. If the thing group exists and has an active deployment, the core device downloads and runs the software that the deployment specifies.

      Note

      The thing group name can't contain colon (:) characters.

    6. GreengrassV2IoTThingPolicy. The name of the Amazon IoT policy that allows the Greengrass core devices to communicate with Amazon IoT and Amazon IoT Greengrass. If the Amazon IoT policy doesn't exist, the installer creates a permissive Amazon IoT policy with this name. You can restrict this policy's permissions for you use case. For more information, see Minimal Amazon IoT policy for Amazon IoT Greengrass V2 core devices.

    7. GreengrassV2TokenExchangeRole. The name of the IAM role that allows the Greengrass core device to get temporary Amazon credentials. If the role doesn't exist, the installer creates it and creates and attaches a policy named GreengrassV2TokenExchangeRoleAccess. For more information, see Authorize core devices to interact with Amazon services.

    8. GreengrassCoreTokenExchangeRoleAlias. The alias to the IAM role that allows the Greengrass core device to get temporary credentials later. If the role alias doesn't exist, the installer creates it and points it to the IAM role that you specify. For more information, see Authorize core devices to interact with Amazon services.

    Linux or Unix
    sudo -E java -Droot="/greengrass/v2" -Dlog.store=FILE \ -jar ./GreengrassInstaller/lib/Greengrass.jar \ --aws-region region \ --thing-name MyGreengrassCore \ --thing-group-name MyGreengrassCoreGroup \ --thing-policy-name GreengrassV2IoTThingPolicy \ --tes-role-name GreengrassV2TokenExchangeRole \ --tes-role-alias-name GreengrassCoreTokenExchangeRoleAlias \ --component-default-user ggc_user:ggc_group \ --provision true \ --setup-system-service true \ --deploy-dev-tools true
    Windows Command Prompt (CMD)
    java -Droot="C:\greengrass\v2" "-Dlog.store=FILE" ^ -jar ./GreengrassInstaller/lib/Greengrass.jar ^ --aws-region region ^ --thing-name MyGreengrassCore ^ --thing-group-name MyGreengrassCoreGroup ^ --thing-policy-name GreengrassV2IoTThingPolicy ^ --tes-role-name GreengrassV2TokenExchangeRole ^ --tes-role-alias-name GreengrassCoreTokenExchangeRoleAlias ^ --component-default-user ggc_user ^ --provision true ^ --setup-system-service true ^ --deploy-dev-tools true
    PowerShell
    java -Droot="C:\greengrass\v2" "-Dlog.store=FILE" ` -jar ./GreengrassInstaller/lib/Greengrass.jar ` --aws-region region ` --thing-name MyGreengrassCore ` --thing-group-name MyGreengrassCoreGroup ` --thing-policy-name GreengrassV2IoTThingPolicy ` --tes-role-name GreengrassV2TokenExchangeRole ` --tes-role-alias-name GreengrassCoreTokenExchangeRoleAlias ` --component-default-user ggc_user ` --provision true ` --setup-system-service true ` --deploy-dev-tools true
    Note

    If you are running Amazon IoT Greengrass on a device with limited memory, you can control the amount of memory that Amazon IoT Greengrass Core software uses. To control memory allocation, you can set JVM heap size options in the jvmOptions configuration parameter in your nucleus component. For more information, see Control memory allocation with JVM options.

    When you run this command, you should see the following messages to indicate that the installer succeeded.

    Successfully configured Nucleus with provisioned resource details! Configured Nucleus to deploy aws.greengrass.Cli component Successfully set up Nucleus as a system service
    Note

    If you have a Linux device and it doesn't have systemd, the installer won't set up the software as a system service, and you won't see the success message for setting up the nucleus as a system service.