How do I run an IoT Job on a GG v2 core?

0

My use case is pretty simple - for remote troubleshooting I want to run an IoT job that will run some arbitrary scripts on one or more greengrass cores. Is there a built-in way to do this?

I'm looking for something similar to what the IoT device client does: https://github.com/awslabs/aws-iot-device-client#jobs-feature

Is there a better way to run arbitrary commands or scripts via a Greengrass v2 core? I suppose I could achieve something similar by using a component and adding it to a deployment, but it feels a bit wrong to do it this way for one-off troubleshooting scripts. Alternately I could create a component that subscribes to some MQTT topic from IoT core and kicks off whatever job I want upon receiving a message in the expected format, but I'm hoping there's something more out-of-the-box that already exists. Thanks!

jjvic
質問済み 3年前380ビュー
2回答
0

I'm looking at this same problem right now. Specifically, how to design a component to update the streams for Stream Manager. I'm thinking of having a special purposes updater component that listens to MQTT messages that contains an updated configuration with an id of the stream. Otherwise, a component would need to be stateful in some way. Alternatively, maybe something similar to the database migration concept used in MS Entity Framework (or others) could allow a run-once regardless of component restarts. This could itself use a permanent persisted stream in stream manager to track the execution of functions within the component itself. The greengrass recipe's Install step is a close a solution, but misses the mark because it re-executes after greengrass launches and I don't know if the proper security (if needed) is applied to scripts that run outside of the Run step.

Edited by: DarrenB on Mar 24, 2021 11:01 AM

DarrenB
回答済み 3年前
0

Hi jjvic,

You are correct about the two options to achieve your use case:

  1. You can define the script in the lifecycle steps in a component, and you can add a logic around it to make sure it's only executed once if required. You can then add this component to a deployment targeting a thing (one device) or a thing group (list of devices). You may need to remove the component in later deployments.
  2. You can create a component which listens on IoT job notifications with IoT device SDKs https://docs.aws.amazon.com/iot/latest/developerguide/iot-sdks.html. The component can process arbitrary scripts from the deployment. This solution seems more extensible for future use as well.

Thanks,
Hui

回答済み 3年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ