Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
AWS IoT Greengrass V2で始める デバイスアプリケーションの継続的開発
Search
wanda
July 19, 2023
Technology
0
1.1k
AWS IoT Greengrass V2で始める デバイスアプリケーションの継続的開発
DevelopersIO 2023 大阪にて登壇時に使用した資料です。
wanda
July 19, 2023
Tweet
Share
More Decks by wanda
See All by wanda
試して分かった!AWS を使った PLCのデータ収集と分析基盤の実践ノウハウ #FA設備技術勉強会#13
ganota
1
16k
AWS IoT SiteWise 導入時に検討するべき3つのポイント
ganota
0
4.9k
SORACOM LTE-M Button Plusと100均ショップの商品でIoTポストを作ってみた
ganota
0
1.5k
Dome9で始めるAWSセキュリティリスク管理.pdf
ganota
0
3.9k
Developers.IO_Nagoya_Well-Architected_Frameworkでクラウドジャーニー.pdf
ganota
0
990
Other Decks in Technology
See All in Technology
開発生産性向上! 育成を「改善」と捉えるエンジニア育成戦略
shoota
2
320
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
1
1.8k
サービスでLLMを採用したばっかりに振り回され続けたこの一年のあれやこれや
segavvy
2
400
多領域インシデントマネジメントへの挑戦:ハードウェアとソフトウェアの融合が生む課題/Challenge to multidisciplinary incident management: Issues created by the fusion of hardware and software
bitkey
PRO
2
100
NilAway による静的解析で「10 億ドル」を節約する #kyotogo / Kyoto Go 56th
ytaka23
3
380
組織に自動テストを書く文化を根付かせる戦略(2024冬版) / Building Automated Test Culture 2024 Winter Edition
twada
PRO
13
3.6k
DevOps視点でAWS re:invent2024の新サービス・アプデを振り返ってみた
oshanqq
0
180
LINEヤフーのフロントエンド組織・体制の紹介【24年12月】
lycorp_recruit_jp
0
530
MLOps の現場から
asei
6
640
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
220
祝!Iceberg祭開幕!re:Invent 2024データレイク関連アップデート10分総ざらい
kniino
2
260
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
190
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
Optimising Largest Contentful Paint
csswizardry
33
3k
The Cult of Friendly URLs
andyhume
78
6.1k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Producing Creativity
orderedlist
PRO
341
39k
Become a Pro
speakerdeck
PRO
26
5k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
The Invisible Side of Design
smashingmag
298
50k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Transcript
AWS IoT Greengrass V 2 2 02 3 / 07
/ 19 AWS
AWS IoT Greengrass Greengrass Development Kit GDK GDK CICD CICD
2
AWS IoT Greengrass AWS CodeCommit, AWS Pipeline, AWS CodeBuild 3
Greengrass 4
myapp.py Recipe zip maven jar S 3 S 3 Greengrass
5
myapp.py Recipe zip maven jar S 3 S 3 Greengrass
6
7 S 3 ʲॻࣜʳ s3://BUCKET_NAME/COMPONENT_NAME/COMPONENT_VERSION/myapp.zip s3://BUCKET_NAME/COMPONENT_NAME/1.0.0/myapp.zip s3://BUCKET_NAME/COMPONENT_NAME/1.0.1/myapp.zip s3://BUCKET_NAME/COMPONENT_NAME/1.0.2/myapp.zip
Greengrass Development Kit 8 Greengrass Greengrass Recipe( ) GDK (gdk-con
fi g.json) URI
GDK 2 GDK 9 $ gdk component build $ gdk
component publish
zip jar S 3 S 3 1 0 ʩ GDKͰࣗಈԽʂ
1 1 GDK Λ CI πʔϧͰ͑ ߋʹ։ൃ͕ޮతʹͳΔ
GDK CICD 1 2
CICD 1 3
AWS CLI GDK CLI GDK GDK 1 4
Buildspec 1 5 phases: install: commands: - curl "https://awscli.amazonaws.com/awscli-exe-linux-$ARCH.zip" -o
"awscliv2.zip" - ./aws/install -i /usr/local/aws-cli -b /usr/local/bin --update - CURRDIR=$(basename "$PWD") - cd ../ && mv $CURRDIR devio2023App && cd devio2023App - python3 -m venv buildenv - . ./buildenv/bin/activate # Install GDK CLI - python3 -m pip install -U git+https://github.com/aws-greengrass/
[email protected]
build: commands: - gdk component build - gdk component publish
CodeBuild CodeCommit myrepo GDK S 3 URI Buildspec 1 6
Ϗϧυ࡞ۀ͢ΔσΟϨΫτϦ໊ΛΞʔςΟϑΝΫτ໊ʹมߋ - CURRDIR=$(basename "$PWD") - cd ../ && mv $CURRDIR devio2023App && cd devio2023App Artifacts: - URI: "s3://BUCKET_NAME/COMPONENT_NAME/COMPONENT_VERSION/devio2023App.zip" Unarchive: ZIP
CodeBuild CodeCommit myrepo GDK S 3 URI Buildspec 1 7
Ϗϧυ࡞ۀ͢ΔσΟϨΫτϦ໊ΛΞʔςΟϑΝΫτ໊ʹมߋ - CURRDIR=$(basename "$PWD") - cd ../ && mv $CURRDIR devio2023App && cd devio2023App Artifacts: - URI: "s3://BUCKET_NAME/COMPONENT_NAME/COMPONENT_VERSION/devio2023App.zip" Unarchive: ZIP NZSFQP㱠EFWJP"QQ ίϯϙʔωϯτϏϧυ/(
CreateDeployment 1 8
Buildspec 1 9 phases: install: commands: - curl "https://awscli.amazonaws.com/awscli-exe-linux-$ARCH.zip" -o
"awscliv2.zip" - unzip awscliv2.zip - ./aws/install -i /usr/local/aws-cli -b /usr/local/bin --update build: commands: - AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query 'Account' --output text) - AWS_REGION=ap-northeast-1 - COMPONENT_NAME=$(cat gdk-con fi g.json | jq -r '.component | keys[]’) - chmod +x ./deploy-components.sh - sh -x ./deploy-components.sh ${AWS_ACCOUNT_ID} ɹɹ${AWS_REGION} ${COMPONENT_NAME} ${IOT_THING_GROUP} ${DEPLOYMENT_NAME} #ݟ͢͞ͷͨΊվߦ
2 0 # ରίϯϙʔωϯτͷ࠷৽όʔδϣϯΛऔಘ LATEST_COMP_VERSION=$(aws greengrassv2 list-components | \ jq
-r '.components[] | select(.componentName == "'"${COMPONENT_NAME}"'").latestVersion' | jq -r '.componentVersion') # ࠷৽ͷσϓϩΠϝϯτIDΛऔಘ DEPLOYMENT_ID=$(aws greengrassv2 list-deployments --target-arn ${THING_GROUP_ARN} | jq -r '.deployments[]' | jq -r .deploymentId) # ରσϓϩΠϝϯτIDʹͱ͍ͮͨσϓϩΠఆٛใΛऔಘɺ৽نʹσϓϩΠఆٛΛ࡞ NEW_CONFIG_JSON=$(aws greengrassv2 get-deployment \ --deployment-id ${DEPLOYMENT_ID} | jq .'components' | jq 'del(."$COMP_NAME")' | \ jq '. += {"'"$COMPONENT_NAME"'": {"componentVersion": "'"$LATEST_COMP_VERSION"'","con fi gurationUpdate":{"reset":[""]}}}') FINAL_CONFIG_JSON='{"components":'$NEW_CONFIG_JSON'}' echo $(echo "$FINAL_CONFIG_JSON" | jq '.') > ${DEPLOYMENT_CONFIG_FILE} # σϓϩΠϝϯτͷ࡞ʢσϓϩΠ࣮ࢪʣ ## set con fi g fi le URI CONFIG_URI=“ fi leb://${DEPLOYMENT_CONFIG_FILE}” ## Deploy aws greengrassv2 create-deployment --target-arn ${THING_GROUP_ARN} \ --deployment-name ${DEPLOYMENT_NAME} \ --cli-input-json ${CONFIG_URI}
2 1 # ࠷৽ͷσϓϩΠϝϯτIDΛऔಘ DEPLOYMENT_ID=$(aws greengrassv2 list-deployments --target-arn ${THING_GROUP_ARN} |
\ jq -r '.deployments[]' | jq -r .deploymentId) ɾෳίϯϙʔωϯτ͕σϓϩΠࡁΈͷ߹ɺͦΕΒͷσϓϩΠใؚΊͯ ɹσϓϩΠ͢Δඞཁ͕͋ΔͨΊɺલͷσϓϩΠϝϯτ*%Λऔಘ ɾσϓϩΠใͷͳ͍ίϯϙʔωϯτʮআʯ͞ΕΔ
2 2 # ରσϓϩΠϝϯτIDʹͱ͍ͮͨσϓϩΠఆٛใΛऔಘɺ৽نʹσϓϩΠఆٛΛ࡞ NEW_CONFIG_JSON=$(aws greengrassv2 get-deployment \ --deployment-id ${DEPLOYMENT_ID}
| jq .'components' | jq 'del(."$COMP_NAME")' | \ jq '. += {"'"$COMPONENT_NAME"'": {"componentVersion": "'"$LATEST_COMP_VERSION"'","con fi gurationUpdate":{"reset":[""]}}}') FINAL_CONFIG_JSON='{"components":'$NEW_CONFIG_JSON'}' echo $(echo "$FINAL_CONFIG_JSON" | jq '.') > ${DEPLOYMENT_CONFIG_FILE} ɾଞͷσϓϩΠࡁΈίϯϙʔωϯτͷσϓϩΠใΛऔಘ ɾ͜ͷεςʔδͰσϓϩΠ͢Δίϯϙʔωϯτͷ࠷৽όʔδϣϯΛؚΊͨσϓϩΠ ɹఆٛΛ࡞
2 3 # σϓϩΠϝϯτͷ࡞ʢσϓϩΠ࣮ࢪʣ ## set con fi g fi
le URI CONFIG_URI=“ fi leb://${DEPLOYMENT_CONFIG_FILE}” ## Deploy aws greengrassv2 create-deployment --target-arn ${THING_GROUP_ARN} \ --deployment-name ${DEPLOYMENT_NAME} \ --cli-input-json ${CONFIG_URI} ɾ࡞ͨ͠σϓϩΠఆٛΛݩʹɺσόΠεͷσϓϩΠʢδϣϒʣΛ࣮ߦ ɹɾσϓϩΠఆٛϑΝΠϧΛΦϓγϣϯͰ͢
JSON ( push) 2 4
Greengrass 2 5
Greengrass PHP Greengrass 2 6
ARM, AMD, RISC-V … 3 2 bit, 6 4 bit
CodeBuild x 86 _ 6 4 , aarch 6 4 x 8 6 32 bit Greengrass Docker 2 7
Docker Buildx multiarch/qemu-user-static CPU 2 8 ηοτΞοϓʹ͕͔͔࣌ؒΔ ख͕͔͔ؒΓ͗͢Δ QEMUͱbinfmt_miscΛ༻ͯ͠ҟͳΔϚϧνΞʔΩςΫνϟͷ ଟ͘ͷΞʔΩςΫνϟΛαϙʔτ
ίϯςφΛ࣮ߦ͢ΔͨΊͷDockerΠϝʔδ
CPU 2 9
AWS 3 0
CodeBuild CPU ECR Docker Manifest List Manifest List AWS 3
1
Greengrass Docker Greengrass Greengrass 3 2 ComponentCon fi guration: DefaultCon
fi guration: MY_TAG: latest ʙதུʙ Manifests: - Lifecycle: Run: "docker container run … xxx.dkr.ecr.xxx.amazonaws.com/myrepo:{con fi guration:/MY_TAG}" Artifacts: - Uri: “docker:xxx.dkr.ecr.xxx.amazonaws.com/myrepo:{con fi guration:/MY_TAG}” Ϩγϐม -JGFDZDMFͷΈ
docker pull, docker run Greengrass 3 3 ComponentCon fi guration:
DefaultCon fi guration: MY_TAG: latest ʙதུʙ Manifests: - Lifecycle: Run: sh -x {artifacts:path}/docker-component-run.sh ‘{con fi guration:/MY_TAG}’ Artifacts: - Uri: s3://όέοτ໊/.../artifacts/ίϯϙʔωϯτ໊/x.x.x/docker-component-run.sh
3 4
Greengrass GDK CPU multiarch/qemu-user-static CodeBuild Greengrass 3 5
None