Cloud9で試すAWS IoT Greengrass V2

354 Views

January 21, 21

スライド概要

JAWS-UG IoT専門支部の会で紹介した「Cloud9で試すAWS IoT Greengrass V2」の資料です。
https://jawsug-iot.connpass.com/event/200026/

2021/1/13時点の情報ですので、最新の情報は、公式のドキュメントを参照してください。
https://docs.aws.amazon.com/greengrass/v2/developerguide/what-is-iot-greengrass.html

profile-image

クラウドで働くIoTおじさん

シェア

またはPlayer版

埋め込む »CMSなどでJSが使えない場合

関連スライド

各ページのテキスト
1.

Cloud9で試す AWS IoT Greengrass V2 JAWS-UG IoT専門支部 2021/01/21 © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

2.

AWS IoT Greengrass AWS IoT GreengrassはデバイスをAWSに接続する方法を提供することで、 レイテンシーとコストを削減し、規制等の問題に対応できます Law of Physics Law of Economics Law of the Land Edge © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Cloud

3.

V2の特徴 © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

4.

Greengrassのソフトウエアはオープンソース Greengrass Core(nucleus)自体がJavaで作られており、ソースコードが公開されている。 一部のpublic componentもオープンソースとして公開されている。 https://github.com/aws-greengrass © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark 6

5.

AWS IoT Greengrass – デバイスのソフトウエアの開発を早く デバイス向けのソフトウエア開 発を速くすることで、本番への 投入を速くし、開発コストを下 げます 特徴 • Greengrassクライアントソフ トウエア自体がオープンソー ス • デバイス側での開発ツール – ローカル向けのCLIとコンソー ルで開発を速く • HW、OS、ランタイムの選択に またがる移植性 AWS Cloud IoT Device Lambda OS process Docker Bring your own runtime Other Greengrass Components AWS IoT Greengrass client software Operating System • ビルド済みまたはカスタムソフト ウェアを使用したモジュラー開 発 © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS IoT Greengrass cloud service

6.

クラウドサービス – 大規模なデバイスソフトウエアのデプロ イ、管理を容易に 大規模なデバイスソフトウエアのデプ ロイと管理を容易にすることで、運用 を単純化しコストを削減できます 特徴 • IoT Thing Groupを利用することで 、大規模なデプロイが可能 • ロールアウトやロールバック、タイ ムアウトなどデプロイの条件を指定 • AWSサービスとの連携を簡単に © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

7.

AWS IoT Greengrass クライアントソフトウエアの機能 ローカルメッセー ジとトリガー データと 状態の同期 ランタイムの 選択 ML 推論 クラウドとの接続 を必要としない メッセージング オフラインでも処理 を継続し、 オンラインになった ら、データを送信 AWS Lambda、Docker イメージ、 シェルスクリプトなど 、エッジで実行できる ランタイム ML 推論を ローカルで実行 © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Stream Manager ストリームデータ をエッジデバイス で収集、処理、 エクスポート Secrets Manager 秘密情報を安全にデバ イスへ展開

8.

AWS IoT Greengrass Tools とクラウドの機能 デバイス管理 コンポーネント デバイスのソフト ウエアとデプロイ を管理 Greengrassが実行されて いるデバイスにデプロイ されるソフトウエアの単 位 Over the Air Updates AWS IoT Greengrass Core自体の アップデート © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Security 相互認証及び認可 をクラウドとロー カル上に Local Tools Local Resource Access CLI とローカルのデバ ッグコンソールで デバイス上での開発を 支援 AWS Lambda ファ ンクションからアク セスできるリソース を設定

9.

AWS IoT Greengrassが使われるデバイス Microcontrollers Microprocessors or AWS IoT Greengrass C-SDK Microprocessors AWS IoT Greengrass © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

10.

手軽に試してみたい https://aws.amazon.com/jp/blogs/news/announcing-aws-iot-greengrass-2-0with-an-open-source-edge-runtime-and-new-developer-capabilities/ © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

11.

手軽に試してみたい https://docs.aws.amazon.com/greengrass/v2/developerguide/setting-up.html © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

12.

Cloud9でAWS IoT Greengrassの 開発環境をセットアップ © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

13.

やること • • • • • • • • Cloud9の起動(Ubuntu 18.04) AWSのクレデンシャル設定 Greengrassのプロビジョニング ローカルでバッグコンソールのデプロイ セキュリティーグループの設定 local debug consoleのパスワード取得 local debug consoleを開く 開発 © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

14.

AWSのクレデンシャルを設定 ターミナルに、以下の環境変数を設定 export AWS_ACCESS_KEY_ID= export AWS_SECRET_ACCESS_KEY= © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

15.
[beta]
Greengrassのプロビジョニング
https://docs.aws.amazon.com/greengrass/v2/developerguide/getting-started.html
curl -s https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip > greengrass-nucleus-latest.zip
unzip greengrass-nucleus-latest.zip -d GreengrassCore && rm greengrass-nucleus-latest.zip
THING_NAME=GREENGRASSV2_DEMO
sudo -E java -Dlog.store=FILE ¥
-jar ./GreengrassCore/lib/Greengrass.jar ¥
--aws-region ap-northeast-1 ¥
--root /greengrass/v2 ¥
--thing-name ${THING_NAME} ¥
--thing-group-name ${THING_NAME}_Group ¥
--tes-role-name ${THING_NAME}_Role ¥
--tes-role-alias-name ${THING_NAME}_Alias ¥
--component-default-user ggc_user:ggc_group ¥
--provision true ¥
--setup-system-service true ¥
--deploy-dev-tools true
sudo chmod 755 /greengrass/v2 && sudo chmod 755 /greengrass

© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

16.

ローカルデバッグコンソールのデプロイ 2) local debug consoleをdeploy 3) 既存のdeployment があればそれを選択 1) local debug consoleを選択 © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

17.

ローカルデバッグコンソールのデプロイ 5) デフォルトの設定を 変更してデプロイ 4) local debug consoleを選択して、設 定変更の画面に © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

18.

local debug consoleのパスワード取得 sudo /greengrass/v2/bin/greengrass-cli get-debug-password local debug consoleを開く ブラウザで http://<Cloud9のIP>:8080/ にアクセス (この手順だとポートを8080に変えているので。デフォルトは1441) © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

19.
[beta]
componentの開発
デプロイ
sudo /greengrass/v2/bin/greengrass-cli --ggcRootPath /greengrass/v2 deployment create ¥
--recipeDir ./python_publish/recipes ¥
--artifactDir ./python_publish/artifacts ¥
--merge "com.example.Pub=1.0.0”

ステータスを確認
sudo /greengrass/v2/bin/greengrass-cli deployment status -i <デプロイのコマンドで出力されたID>

削除
sudo /greengrass/v2/bin/greengrass-cli --ggcRootPath /greengrass/v2 deployment create ¥
--recipeDir ./python_publish/recipes ¥
--remove com.example.Pub

https://docs.aws.amazon.com/greengrass/v2/developerguide/interact-with-aws-services.html
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

20.

V1とV2 どちらを使えば良いのか? (2021/1/13時点) © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

21.

サポートされている環境 (2021/1/13時点) アーキテクチャ • Armv7l • • • Linux(動作確認済みRaspberry Pi OS 2020-08-24) • Linux(Amazon Linux2, Ubuntu 18.04) Armv8(AArch64) x86_64 • Linux(Amazon Linux2, Ubuntu 18.04) メモリ • 最低128MBのRAMがGreengrass Coreに必要 ストレージ • 最低256MBがGreengrass Coreに必要 Javaバージョン • Java8以上 https://docs.aws.amazon.com/greengrass/v2/developerguide/setting-up.html#greengrass-v2-requirements © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

22.

V2で提供されていない機能(2021/1/13現在) • • Greengrassがlocal connected deviceを管理する仕組み デバイスのローカルShadow、shadowのクラウド同期 • • • • • Core自体のshadowはcomponentから必要なtopicにサブスクライブしたり、パブリッ シュすることで利用は可能 HSM(Hardware security integration) StreamManagerのテレメトリデータ送信 NodeJS、C向けのAWS IoT Greengrass SDK C, C++で作成されたLambda function • カスタムcomponentには、利用可能言語の制限は特にない 上記に書かれている機能が必須の場合、V1の利用を検討 © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

23.

V1で提供されている機能の扱い (2021/1/13時点) v1機能 v2 ローカルメッセージとトリガー Greengrass Groupが無くなり、ローカルネットワークで連携するデバ イスを含めたメッセージングは現在提供されていない。component間 のメッセージはIPC(inter process communicationを使って行われる ローカルアクション(Lambda) Lambdaを実行・管理するためのcomponentがあるので、それを使っ て実行。V1のサブスクリプションの設定も専用のcomponentを利用 データの状態の同期 local shadowは現在提供されていない セキュリティー Groupに含まれているデバイスとの相互認証に関する機能は、現在 提供されていない ローカルリソースアクセス Lambdaを利用する場合は指定可能。カスタムcomponentを作成した 場合は、コンテナ外で動作するので、指定不要。 OTA OTA agentは提供されず、nuclues componentのデプロイで可能 © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

24.

V1で提供されている機能の扱い (2021/1/13時点) v1機能 v2 機械学習の推論 componentに推論アプリとモデルを含めて利用。 コネクター 多くのコネクターはpublic componentとして利用可能。(SiteWiseなど、 一部は未対応) シークレットマネージャー public componentとして提供(*1) コンテナのサポート カスタムcomponentでアーティファクトとしてDockerイメージを指定可 能 ストリームマネージャー public componentとして提供 *1: StreamManagerを利用するためのクライアントライブラリ Python: https://github.com/aws-greengrass/aws-greengrass-stream-manager-sdk-python Java: https://github.com/aws-greengrass/aws-greengrass-stream-manager-sdk-java JavaScript: https://github.com/aws-greengrass/aws-greengrass-stream-manager-sdk-js © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

25.

Thank you! © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark