Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
初めてのIoT with Python on AWS
Search
smokeymonkey
September 12, 2015
Technology
3k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
初めてのIoT with Python on AWS
2015/9/12 PyCon mini Sapporo
http://sapporo.pycon.jp/2015/
smokeymonkey
September 12, 2015
More Decks by smokeymonkey
See All by smokeymonkey
StackHawkを使ってWebアプリケーションの脆弱性を診断する
smokeymonkey
0
2.7k
内製化をネクストステージへ〜クラスメソッドのSaaSソリューション〜
smokeymonkey
0
1.4k
Digital waiting room that supported vaccination reservations
smokeymonkey
0
1.4k
完全テレワークを実現した企業のカルチャーを支える Slack 活用実践事例
smokeymonkey
0
2.1k
ケーススタディで学ぶ企業運営〜クラスメソッドの新型コロナ対応〜
smokeymonkey
3
2.2k
ピンチをチャンスに変える!カルチャートランスフォーメーション
smokeymonkey
1
2.7k
テックブログとCI
smokeymonkey
0
9.9k
40分で理解するAWS re:Invent 2019アップデートまとめ
smokeymonkey
0
1.8k
EmulatingAmazon GO
smokeymonkey
0
1.8k
Other Decks in Technology
See All in Technology
Slack上でインフラをトラブルシュートする! Agentic Platform Engineeringの第一歩
teru0x1
5
1.8k
AIで社員の自主発信に広報目線を組み込む
_mossann_t
0
120
AIエージェントの一手は 誰も見ていない - Falco拡張OSS「Prempti」とeBPFで サーバーレス実行基盤を二層防御する
keitah
0
160
作って終わりじゃないサーバーレス 〜9年運用する大規模EC物流API基盤の設計・運用のリアル〜
zozotech
PRO
0
130
HHKBエバンジェリストになる方法
941
0
110
データ界隈LT祭 第1回LT登壇
taromatsui_cccmkhd
2
1.4k
AI de Idea
kawaguti
PRO
2
120
AI 時代のスタートアップエコシステ厶から考究する技術的負債との向き合い方
m3m0r7
PRO
3
2.2k
HRC_Frontend_Conference_Fukuoka_2026.pdf
ts020
0
740
Reactの設計論
uhyo
24
14k
銀行勘定系システムにおける開発プロセス刷新×AIによる環境モダナイゼーション / Development Process Transformation and AI-Driven Environment Modernization
muit
1
2.3k
LLMに渡さなかった仕事
nanaism
0
670
Featured
See All Featured
Bash Introduction
62gerente
615
220k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
370
First, design no harm
axbom
PRO
2
1.3k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
RailsConf 2023
tenderlove
30
1.5k
Designing Powerful Visuals for Engaging Learning
tmiket
1
560
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Exploring anti-patterns in Rails
aemeredith
4
510
Typedesign – Prime Four
hannesfritz
42
3.2k
Making the Leap to Tech Lead
cromwellryan
135
10k
Deep Space Network (abreviated)
tonyrice
0
310
Transcript
DMBTTNFUIPEKQ ॳΊͯͷ*P5 XJUI1ZUIPOPO"84 1Z$PONJOJ4BQQPSP 1 Ϋϥεϝιουגࣜձࣾ ࠤʑɹେี
classmethod.jp 2 w ࣗݾհ w *P5ͷ֓ཁ w *P5PO"84 w *P5XJUI1ZUIPOPO"84σϞ
ΞδΣϯμ
classmethod.jp 3 ࣗݾհ
4 classmethod.jp 4 ࣗݾհ ࠤʑɹେี !TNPLFZNPOLFZBLB͚͢ 5XJUUFS'BDFCPPL
classmethod.jp 5 ࣗݾհ w Ϋϥεϝιουגࣜձࣾ w "84ίϯαϧςΟϯά෦ɹ෦ w ࡳຈΦϑΟεɹΤϦΞϚωʔδϟ w
γχΞιϦϡʔγϣϯΞʔΩςΫτ w ಘҙͳͷ w ωοτϫʔΫηΩϡϦςΟ w ͖ͳ"84αʔϏε w 71$
6
classmethod.jp 7 ࣗݾհ w Ϋϥεϝιουגࣜձࣾ w "84ίϯαϧςΟϯά෦ɹ෦ w ࡳຈΦϑΟεɹΤϦΞϚωʔδϟ w
γχΞιϦϡʔγϣϯΞʔΩςΫτ w ಘҙͳͷ w ωοτϫʔΫηΩϡϦςΟ w ͖ͳ"84αʔϏε w 71$
classmethod.jp 8 ͱ 1ZUIPO ؔͳ͍
classmethod.jp 9 ΑΖ͘͠ ͓ئ͍͠·͢
classmethod.jp 10 *P5ͷ֓ཁ
classmethod.jp 11 w ʮϞϊͷΠϯλʔωοτʯ w Ϟϊ͕ɺΠϯλʔωοτΛհͯ͠ɺ ใͷΓऔΓΛ͢Δ͜ͱ w ϞϊˠใͷΓऔΓ͕Ͱ͖Δͷ w
ύιίϯ w εϚʔτϑΥϯ w γϯάϧϘʔυίϯϐϡʔλ w σδλϧՈి *P5 *OUFSOFUPG5IJOHT ͱ
classmethod.jp 12 w ઍສͷϚγϯσόΠε͕ɺ w ਓΛհ͢Δ͜ͱͳ͘ɺ w ϚγϯؒͰσʔλ௨৴Λߦ͏͜ͱͰɺ w ΑΓߴ͍ՁαʔϏεΛఏڙ͢ΔΈ
ࠓݱࡏޠΒΕ͍ͯΔ*P5ͱ
classmethod.jp 13 w ӡૹंʹऔΓ͚ͨηϯαʔͰߦҐஔɺ ɺ೩අɺߦڑɺఀࢭճͳͲΛه w ˠΞΠυϦϯά೩ྉফඅΛݮ w ˠੳʹΑΓӡૹܦ࿏Λ࠷దԽ w
Ոͷാͷʹؚ·ΕͨਫϨϕϧΛه w ˠԹɺ࣪ɺࣹྔɺӍྔΛܭଌ w ˠࠓޙͷಈΛੳ *P5ʹΑͬͯԿ͕Ͱ͖Δͷ͔
classmethod.jp 14 *P5ͷ Ұൠతͳ ߏཁૉ センサー デバイス ネットワーク サーバ 加速度度センサー
温湿度度センサー GPS ジャイロスコープ e.t.c...... デジタル家電 Intel Edison Raspberry Pi Armadillo e.t.c...... 4G LTE 3G Wi-‐‑‒Fi Bluetooth LE e.t.c......
classmethod.jp 15 w ˠ w 530/ͷࡔଜઌੜ w ʮͲ͜Ͱίϯϐϡʔλʯ w ˠ
w 1"3$ͷϚʔΫɾϫΠβʔ w ʮϢϏΩλείϯϐϡʔςΟϯάʯ w ˠ w ଜ૯ݚ w ʮϢϏΩλεωοτϫʔΫʯ w ͋ΒΏΔॴͰ͋ΒΏΔϞϊ͕ωοτϫʔ Ϋʹͭͳ͕Δ *P5ͷ֓೦৽͍͠ͷͰແ͍
classmethod.jp 16 w σόΠεͷීٴ w ίϯϐϡʔλνοϓͷੑೳ্ɺলిྗԽɺՁ ֨Խ w γϯάϧϘʔυίϯϐϡʔλͳͲͷۃখԽ w
ωοτϫʔΫͷීٴ w 8J'Jͷීٴ w ((ͷ෮چ ֨҆4*.ؚΉ w ΫϥυαʔϏεͷීٴ w "84($&"[VSFFUD w ߴੑೳͳαʔόϦιʔεΛɺखܰʹɺ֨҆ʹ͑ ΔΑ͏ʹͳͬͨ ͳͥࠓ*P5ͳͷ͔
classmethod.jp 17 *P5Λ࣮ݱ͢Δ ͕ἧͬͨ ͔Β
classmethod.jp 18 *P5PO"84
classmethod.jp 19 "84Ͱ*P5ʹؔ࿈͢Δ දతͳ αʔϏε w ଞʹͨ͘͞Μ͋Δ w දతͳͷΛ͝հ センサー
Amazon Kinesis AWS Lambda Amazon DynamoDB Amazon Redshift リアルタイム ダッシュボー ド ビッグデータ 分析
classmethod.jp 20 w ετϦʔϛϯάσʔλॲཧͷҝͷϚωʔδυαʔϏε w େྔͷηϯαʔσόΠεͳͲ͔ΒσʔλΛड͚औΓɺ όοΫΤϯυܨ͙͜ͱ͕Մೳ w σʔλͷऔΓग़͠,JOFTJT$MJFOU-JCSBSZɺ,JOFTJT $POOFDUPSɺ"NB[PO-BNCEBͳͲΛ͏ɻ
"NB[PO,JOFTJT Data Sources Data Data Data Data INPUT KEEP Processer OUTPUT Amazon Kinesis 処理理
classmethod.jp w ΠϕϯτυϦϒϯͰϢʔβʔಠࣗͷίʔυΛ࣮ߦͤ͞ ΔίϯϐϡʔςΟϯάαʔϏε w Πϯελϯε04ͳͲͷཧෆཁ w ຖ͔݅Βຖඵઍ݅·Ͱࣗಈతʹεέʔϧ w +BWB4DSJQU·ͨ+BWBͰίʔσΟϯάՄೳ
"84-BNCEB Event Sources EVENT INPUT 発⽕火 AWS Lambda 実⾏行行結果 21
classmethod.jp w ϑϧϚωʔδυͳ/P42-σʔλϕʔεαʔϏε w ߴͰҰ؏ͨ͠ύϑΥʔϚϯε w ߴ͍εέʔϥϏϦςΟ w ΩʔόϦϡʔܕͱ+40/υΩϡϝϯτʹରԠ w
σʔλॻ͖ࠐΈ͕ଟ͘ɺ͔ͭߋ৽݁Ռ߹ੑͰ୲อ ͞ΕΕྑ͍έʔεʹ͍ͯΔ w ߦಈϩά w ιγϟήͷϙΠϯτ w ϦΞϧλΠϜμογϡϘʔυ "NB[PO%ZOBNP%# 22
classmethod.jp w ϖλόΠτنͷϑϧϚωʔδυσʔλΣΞϋε w ྻࢦσʔλϕʔε w ΧϥϜ୯ҐͰσʔλΛߴʹूܭ w ߴ͍εέʔϥϏϦςΟ w
.11ػߏΛ࣋ͪɺશϊʔυ͕ฒྻʹॲཧ w ϊʔυΛ૿ͤॲཧੑೳ্ "NB[PO3FETIJU
classmethod.jp 24 *P5 XJUI1ZUIPO PO"84 σϞ
classmethod.jp σϞͷ༰ w *OUFM&EJTPOʹଓ͞ΕͨޫηϯαʔͰ໌ Λऔಘ w *OUFM&EJTPO্ͷ"844%,GPS1ZUIPOͰޫ ηϯαʔͷσʔλΛ"NB[PO,JOFTJTʹQVU w ,JOFTJTʹొ͞ΕͨσʔλΛ֬ೝ
光センサー Amazon Kinesis AWS SDK for Python on Intel Edison 25
classmethod.jp *OUFM&EJTPO-JHIU4FOTPS
classmethod.jp 4FOEFS *OUFM&EJTPO 27 import boto3 from boto3.session import
Session import mraa import time account_̲id = '<YOUR_̲ACCOUNT_̲ID>' identity_̲pool_̲id = '<YOUR_̲IDENTITY_̲POOL_̲ID>' role_̲arn = '<YOUR_̲COGNITO_̲UNAUTH_̲ARN>' aws_̲region = 'us-‐‑‒east-‐‑‒1' stream_̲name = '<YOUR_̲STREAM_̲NAME>' partition_̲key = 'PartitionKey' Boto3を使⽤用 mraaを使⽤用 ※Intel謹製のIOフレームワーク
classmethod.jp 4FOEFS *OUFM&EJTPO 28 light = mraa.Aio(0) client =
boto3.client('cognito-‐‑‒identity', aws_̲region) resp = client.get_̲id(AccountId=account_̲id,IdentityPoolId=identity_̲pool_̲id) resp = client.get_̲open_̲id_̲token(IdentityId=resp['IdentityId']) token = resp['Token'] client = boto3.client('sts') assumeRole = client.assume_̲role_̲with_̲web_̲identity( RoleArn = role_̲arn, RoleSessionName = 'boto', WebIdentityToken = token) Analog(0)が光センサー CognitoからToken取得 STSから AssumeRole取得
classmethod.jp 4FOEFS *OUFM&EJTPO 29 session = Session( aws_̲access_̲key_̲id
= assumeRole['Credentials'] ['AccessKeyId'], aws_̲secret_̲access_̲key = assumeRole['Credentials'] ['SecretAccessKey'], aws_̲session_̲token = assumeRole['Credentials'] ['SessionToken'], region_̲name = aws_̲region ) kinesis = session.client('kinesis') Kinesis clientを作成 AssumeRoleを認証情報として使⽤用
classmethod.jp 4FOEFS *OUFM&EJTPO 30 while True:
data = light.read() time.sleep(0.2) response = kinesis.put_̲record( StreamName = stream_̲name, Data = str(data), PartitionKey = partition_̲key) print(response) 光センサーの 値を取得 Kinesisにput
classmethod.jp 3FDFJWFS 1$ 31 from boto3.session import Session import
time aws_̲region = 'us-‐‑‒east-‐‑‒1' stream_̲name = 'pycon' partition_̲key = 'PartitionKey' session = Session( aws_̲access_̲key_̲id = '<YOUR_̲ACCESS_̲KEY>', aws_̲secret_̲access_̲key = '<YOUR_̲SECRET_̲KEY>', region_̲name = aws_̲region ) Boto3を使⽤用 認証情報をセット
classmethod.jp 3FDFJWFS 1$ 32 kinesis = session.client('kinesis') stream =
kinesis.describe_̲stream(StreamName=stream_̲name) shards = stream['StreamDescription']['Shards'][0] ['ShardId'] shared_̲iterator = kinesis.get_̲shard_̲iterator( StreamName = stream_̲name, ShardId = shards, ShardIteratorType = 'LATEST' ) Kinesisに 接続 接続するShardIteratorを取得
classmethod.jp 3FDFJWFS 1$ 33 iterator = shared_̲iterator['ShardIterator'] while True:
resp = None resp = kinesis.get_̲records(ShardIterator=iterator,Limit=1) print resp['Records'] iterator = resp['NextShardIterator'] time.sleep(1) 最初のIteratorを取得 データをgetして出⼒力力し、 次のIteratorを取得
classmethod.jp 34 ಈ͔ͯ͠ΈΔ
classmethod.jp 35 ·ͱΊ
classmethod.jp 36 w *P5ͷ׆༻ʹΫϥυαʔϏεͷ ར༻ඞਢ w "84ʹ*P5ʹඞཁͳαʔϏε͕ ͨ͘͞Μἧ͍ͬͯΔ w 1ZUIPOΛͬͯ؆୯ʹηϯαʔσʔ
λΛ"84ʹ1VUͰ͖Δ ·ͱΊ
classmethod.jp 37 "84ͱ1ZUIPOΛ ׆༻ͯ͠ *P5Ͱ༡΅͏ ·ͱΊ
None