This sample uses the AWS IoT Greengrass IPC Client to defined a Greengrass component that subscribes to MQTT messages on a topic in AWS IoT Core and periodically publishes messages to that topic.
Note: For this sample to work, you must have configured and installed the AWS Greengrass software on the local host. The IAM role assumed by the Greengrass Nucleus must also include permissions to connect, subscribe, and publish to AWS IoT Core.
First, go to the ./artifacts/com.amazon.RpcTest/1.0.0 folder and run the following command:
npm installThen, from this folder, run the following Greengrass CLI command:
Linux:
sudo <path-to-greengrass-cli-executable> deployment create --recipeDir ./recipes --artifactDir ./artifacts --merge "com.amazon.RpcTest=1.0.0"Windows:
<path-to-greengrass-cli-executable> deployment create --recipeDir ./recipes --artifactDir ./artifacts --merge "com.amazon.RpcTest=1.0.0"Check your nucleus logs and component log for details about the success of the deployment and component execution. See the AWS Greengrass Documentation for more details about Greengrass components, Greengrass IPC, and the Greengrass CLI.
These code examples interact with services that may incur charges to your AWS account. For more information, see AWS Pricing.
Additionally, example code might theoretically modify or delete existing AWS resources. As a matter of due diligence, do the following:
- Be aware of the resources that these examples create or delete.
- Be aware of the costs that might be charged to your account as a result.
- Back up your important data.