Creating component

Creating component artifacts

  1. Execute the following command in the terminal of Cloud9 environment to create a folder of artifacts and an empty script file
mkdir -p ~/environment/GreengrassCore/artifacts/com.example.HelloWorld/1.0.0 && touch ~/environment/GreengrassCore/artifacts/com.example.HelloWorld/1.0.0/

The path of the artifact must always follow the following format: artifacts/componentName/componentVersion/. componentName and componentVersion are specified in the recipe created in the next step.

  1. Open the created script file and paste the following source code


# Copyright, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
import sys
import datetime
import time

while True:
    message = f"Hello, {sys.argv[1]}! Current time: {str(}."
    # Print the message to stdout.
    # Append the message to the log file.
    with open('/tmp/Greengrass_HelloWorld.log', 'a') as f:
        print(message, file=f)

Make sure to save after each copy/paste in Cloud9 Editor pane.

Creating a recipe for a component

You have an option to write your recipe in either YAML or JSON, in this workshop we will use JSON.

  1. Execute the following command to create a folder to put the recipe and an empty file
mkdir -p ~/environment/GreengrassCore/recipes && touch ~/environment/GreengrassCore/recipes/com.example.HelloWorld-1.0.0.json 
  1. Open the created recipe file com.example.HelloWorld-1.0.0.json, paste the following contents and save


   "RecipeFormatVersion": "2020-01-25",
   "ComponentName": "com.example.HelloWorld",
   "ComponentVersion": "1.0.0",
   "ComponentDescription": "My first AWS IoT Greengrass component.",
   "ComponentPublisher": "Amazon",
   "ComponentConfiguration": {
      "DefaultConfiguration": {
         "Message": "world"
   "Manifests": [
         "Platform": {
            "os": "linux"
         "Lifecycle": {
            "Run": "python3 {artifacts:path}/ '{configuration:/Message}'\n"

If you encounter any issues during the workshop, first see if you can find your solution in Troubleshooting section