Run and test component

Deploy sample components

  1. Create a new terminal screen as shown in the image below

Cloud9DisableTempUser

  1. Execute the following command to display the Greengrass log. This will remain open for subsequent steps.
sudo tail -F /greengrass/v2/logs/greengrass.log

Since the component deployment command etc. performed in this procedure is executed asynchronously on Greengrass, the error etc. when the deployment fails due to the incorrect recipe description is not displayed as the command execution result. Instead, greengrass.log writes event logs such as component updates, which can be useful for troubleshooting.

  1. Run the following command to deploy the created component to the Greengrass core device
sudo /greengrass/v2/bin/greengrass-cli deployment create \
  --recipeDir ~/environment/GreengrassCore/recipes \
  --artifactDir ~/environment/GreengrassCore/artifacts \
  --merge "com.example.HelloWorld=1.0.0"

Once you have run the command you will see similar output

INFO: Connection established with event stream RPC server
Local deployment submitted! Deployment Id: 2b79b12d-1888-4574-a335-86df3b90528b
  1. In few minutes, the deployed components will start running. Execute the following command to display the log that the created component logs out.
tail -F /tmp/Greengrass_HelloWorld.log

Once we see the following message, it means it has successfully deployed.

Hello, world! Current time: 2021-03-11 17:48:59.153933.

For other details on how to use the Greengrass CLI, see here.