1.- 创建一个core device
创建1部EC2作为core device,过程如下


复制相关命令在EC2上跑即可,完成后检查:/greengrass/v2/bin/greengrass-cli -V

2.- 创建component
components consist of two types of files:
--artifact, The artifact files contain the scripts, compiled code, or any other resources that the component requires.
--recipe, The recipe file contains the metadata and configuration information for the component, such as the platform it can run on, parameter settings, commands to install, run, or shut down the component, and the location of the artifact files.
默认文件已经放在:/home/ec2-user/greenhouse_components
/greenhouse_components/artifacts/com.greenhouse.VentilationControl/1.0.0/controller.py
/greenhouse_components/recipes/com.greenhouse.VentilationControl-1.0.0.json
3.- 本地直接deploy component
Before you deploy the ventilation control component into production, you would like to perform a local test to ensure it functions as you intend it to.
sudo /greengrass/v2/bin/greengrass-cli deployment create --recipeDir ~/greenhouse_components/recipes --artifactDir ~/greenhouse_components/artifacts --merge "com.greenhouse.VentilationControl=1.0.0"

验证:tail /tmp/ventilation_control.log

查看已安装的所有component
sudo /greengrass/v2/bin/greengrass-cli component list

If the component does not seem to deploy correctly, or you are not receiving similar results to the verification steps, run the following command to view the Greengrass log file:
sudo tail /greengrass/v2/logs/greengrass.log4.- 通过AWS IoT部署component
将artifact文件上传到S3

创建component

将receip的json文件内容copy进去

注意更正artifact的S3路径



5.- 创建Deployment
先删除之前在本地上部署的用于验证目的的component
sudo /greengrass/v2/bin/greengrass-cli deployment create --remove com.greenhouse.VentilationControl





后面按默认Next
完成后,稍等一会可以查看部署情况

在EC2上查看:sudo /greengrass/v2/bin/greengrass-cli component list


















