More Related Content
Similar to Cloud9で試すAWS IoT Greengrass V2 (20)
More from Jun Ichikawa (20)
Cloud9で試すAWS IoT Greengrass V2
- 1. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Cloud9で試す
AWS IoT Greengrass V2
JAWS-UG IoT専門支部
2021/01/21
- 2. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Edge Cloud
Law of Economics
Law of Physics
Law of the Land
AWS IoT GreengrassはデバイスをAWSに接続する方法を提供することで、
レイテンシーとコストを削減し、規制等の問題に対応できます
AWS IoT Greengrass
- 3. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
V2の特徴
- 4. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
6
Greengrassのソフトウエアはオープンソース
Greengrass Core(nucleus)自体がJavaで作られており、ソースコードが公開されている。
一部のpublic componentもオープンソースとして公開されている。
https://github.com/aws-greengrass
- 5. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS IoT Greengrass – デバイスのソフトウエアの開発を早く
デバイス向けのソフトウエア開
発を速くすることで、本番への
投入を速くし、開発コストを下
げます
特徴
• Greengrassクライアントソフ
トウエア自体がオープンソー
ス
• デバイス側での開発ツール –
ローカル向けのCLIとコンソー
ルで開発を速く
• HW、OS、ランタイムの選択に
またがる移植性
• ビルド済みまたはカスタムソフト
ウェアを使用したモジュラー開
発
AWS Cloud
IoT Device
Operating System
Greengrass Components
Lambda Docker
Bring
your own
runtime
AWS IoT Greengrass client software
OS
process Other
AWS IoT Greengrass
cloud service
- 6. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
クラウドサービス – 大規模なデバイスソフトウエアのデプロ
イ、管理を容易に
大規模なデバイスソフトウエアのデプ
ロイと管理を容易にすることで、運用
を単純化しコストを削減できます
特徴
• IoT Thing Groupを利用することで
、大規模なデプロイが可能
• ロールアウトやロールバック、タイ
ムアウトなどデプロイの条件を指定
• AWSサービスとの連携を簡単に
- 7. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS IoT Greengrass クライアントソフトウエアの機能
ローカルメッセー
ジとトリガー
クラウドとの接続
を必要としない
メッセージング
データと
状態の同期
オフラインでも処理
を継続し、
オンラインになった
ら、データを送信
ML 推論
ML 推論を
ローカルで実行
Stream
Manager
ストリームデータ
をエッジデバイス
で収集、処理、
エクスポート
Secrets
Manager
秘密情報を安全にデバ
イスへ展開
ランタイムの
選択
AWS Lambda、Docker
イメージ、
シェルスクリプトなど
、エッジで実行できる
ランタイム
- 8. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS IoT Greengrass Tools とクラウドの機能
コンポーネント
Greengrassが実行されて
いるデバイスにデプロイ
されるソフトウエアの単
位
デバイス管理
デバイスのソフト
ウエアとデプロイ
を管理
Over the Air
Updates
AWS IoT Greengrass
Core自体の
アップデート
Local Resource
Access
AWS Lambda ファ
ンクションからアク
セスできるリソース
を設定
Security
相互認証及び認可
をクラウドとロー
カル上に
Local
Tools
CLI とローカルのデバ
ッグコンソールで
デバイス上での開発を
支援
- 9. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS IoT Greengrassが使われるデバイス
Microcontrollers Microprocessors
Microprocessors
AWS IoT
Greengrass
AWS IoT
Greengrass
or
C-SDK
- 10. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
手軽に試してみたい
https://aws.amazon.com/jp/blogs/news/announcing-aws-iot-greengrass-2-0-
with-an-open-source-edge-runtime-and-new-developer-capabilities/
- 11. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
手軽に試してみたい
https://docs.aws.amazon.com/greengrass/v2/developerguide/setting-up.html
- 12. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Cloud9でAWS IoT Greengrassの
開発環境をセットアップ
- 13. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
やること
• Cloud9の起動(Ubuntu 18.04)
• AWSのクレデンシャル設定
• Greengrassのプロビジョニング
• ローカルでバッグコンソールのデプロイ
• セキュリティーグループの設定
• local debug consoleのパスワード取得
• local debug consoleを開く
• 開発
- 14. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWSのクレデンシャルを設定
ターミナルに、以下の環境変数を設定
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
- 15. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Greengrassのプロビジョニング
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
https://docs.aws.amazon.com/greengrass/v2/developerguide/getting-started.html
- 16. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
ローカルデバッグコンソールのデプロイ
3) 既存のdeployment
があればそれを選択
1) local debug
consoleを選択
2) local debug
consoleをdeploy
- 17. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
ローカルデバッグコンソールのデプロイ
4) local debug
consoleを選択して、設
定変更の画面に
5) デフォルトの設定を
変更してデプロイ
- 18. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
local debug consoleのパスワード取得
sudo /greengrass/v2/bin/greengrass-cli get-debug-password
local debug consoleを開く
ブラウザで http://<Cloud9のIP>:8080/ にアクセス
(この手順だとポートを8080に変えているので。デフォルトは1441)
- 19. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
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
- 20. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
V1とV2
どちらを使えば良いのか?
(2021/1/13時点)
- 21. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
サポートされている環境 (2021/1/13時点)
アーキテクチャ
• Armv7l
• Linux(動作確認済みRaspberry Pi OS 2020-08-24)
• Armv8(AArch64)
• Linux(Amazon Linux2, Ubuntu 18.04)
• 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
- 22. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
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の利用を検討
- 23. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
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のデプロイで可能
- 24. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
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
- 25. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Thank you!