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-lambda-in-practice
Search
tannai
February 20, 2016
Technology
2
1.9k
aws-lambda-in-practice
tannai
February 20, 2016
Tweet
Share
More Decks by tannai
See All by tannai
redash patche at dmm
yuukigoodman
0
680
akibago-2018-10-30
yuukigoodman
0
67
serverless-design-and-streaming-date-processing-service
yuukigoodman
0
860
alexa-changes-development-process
yuukigoodman
0
1.3k
VUIとAlexaによるちょっと未来の体験の話2
yuukigoodman
0
780
regrowth2016alexa
yuukigoodman
0
1.1k
Rails App Deployment with CodeDeploy
yuukigoodman
0
1.3k
cognito-userpools-in-production
yuukigoodman
4
8.4k
serverless-from-today
yuukigoodman
2
2k
Other Decks in Technology
See All in Technology
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
28
12k
OCI Security サービス 概要
oracle4engineer
PRO
0
6.5k
SREによる隣接領域への越境とその先の信頼性
shonansurvivors
2
520
Amazon Personalizeのレコメンドシステム構築、実際何するの?〜大体10分で具体的なイメージをつかむ〜
kniino
1
100
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
130
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.3k
Shopifyアプリ開発における Shopifyの機能活用
sonatard
4
250
強いチームと開発生産性
onk
PRO
34
11k
OTelCol_TailSampling_and_SpanMetrics
gumamon
1
130
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
180
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
2
310
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
120
Featured
See All Featured
How to Ace a Technical Interview
jacobian
276
23k
Fireside Chat
paigeccino
34
3k
Code Review Best Practice
trishagee
64
17k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
The Invisible Side of Design
smashingmag
298
50k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
The Cost Of JavaScript in 2023
addyosmani
45
6.7k
Ruby is Unlike a Banana
tanoku
97
11k
Side Projects
sachag
452
42k
Gamification - CAS2011
davidbonilla
80
5k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Music & Morning Musume
bryan
46
6.2k
Transcript
%FWFMPQFST*0 -B ୮༏لϞόΠϧΞϓϦαʔϏε෦ Ϋϥεϝιουגࣜձࣾ ⡥$MBTTNFUIPE *OD ݄ ࣮Ͱ͏"84-BNCEB #cmdevio2016
#La
ࣗݾհ • ୮༏ل • Ϋϥεϝιουגࣜձࣾ • ϞόΠϧΞϓϦαʔϏε෦ • αʔόαΠυ୲ 2
#cmdevio2016 #La
ϞόΠϧόοΫΤϯυάϧʔϓ • AWSͱiOS/Androidͷهࣄ͕ଟ͍Classmethod • ࢢͷมԽʹରԠͯ͠αʔόαΠυͷ։ൃ ڧԽ • AWS্Ͱಈ͘APIαʔόWebΞϓϦͷ։ൃ • ্ཱͪ͛ظʹ͖ͭืूதʂ
3 #cmdevio2016 #La
ຊ 4
Agenda • AWS Lambdaͱ࣮ • ࣮ͰͷϢʔεέʔε • LambdaͷTips • ࣮ʹΈࠐΉצॴ
5
AWS Lambdaͱ • https://aws.amazon.com/jp/lambda/faqs/ • ొͨ͠ϓϩάϥϜΛ࣮ߦͯ͘͠ΕΔ ϑϧϚωʔδυαʔϏε • EC2ͷΑ͏ͳཧ͢Βෆཁ •
ϑϧϚωʔδυ • AWSͱͷ࿈ܞ͕ڧྗ • Πϕϯτιʔε 6 #cmdevio2016 #La
࣮ͱ • ࣮ࡍͷ۩ମతͳࣄ • https://kotobank.jp/word/࣮-521746 • ʮΛՌ͓ͨͯۚ͠ΛΒ͏ʯ • ظݶ/είʔϓ/༧ࢉͷ͍͔͕ܾͭ͘·͍ͬͯΔ 7
#cmdevio2016 #La
ͪΐͬͱͰLambdaΛ ͬͨ͜ͱ͕͋Δਓ 8
࣮ͰLambdaΛ ͍ͬͯΔਓ 9
࣮ͰLambdaΛ ͕ͬͭΓ͍ͬͯΔਓ 10
࣮ͰLambdaΛ͏ͷ͍͠ʁ • Lambda͕ྑͦ͞͏ͳ͜ͱ͔Δ • EC2ͰΦϯϓϨͱಉ͡Α͏ʹϓϩάϥϜΛ ࣮ߦ͢Δ͜ͱ͕Ͱ͖ͨ • Lambdaͷ͍ํɺͦΕͱҟͳΔ • ೲظ͕ܾ·͍ͬͯΔͷͰԼखʹϋϚΔͱਏ͍
• ӡ༻࣌ʹ͕ग़ΔͱࠔΔ 11 #cmdevio2016 #La
͜ͷηογϣϯͷΰʔϧ • LambdaΛ࣮Ͱ͏͖͔͚ͬʹͳΔ • ࣮ʹແཧͳ͘औΓೖΕΒΕΔઃܭͷ ͖͔͚ͬΛಘΔ 12 #cmdevio2016 #La
Agenda • AWS Lambdaͱ࣮ • ࣮ͰͷϢʔεέʔε • LambdaͷTips • ࣮ʹΈࠐΉצॴ
13
S3ϑΝΠϧૢ࡞ 14
S3ϑΝΠϧૢ࡞ • ϝλσʔλ༩ • αϜωΠϧ࡞ 15 #cmdevio2016 #La
CSVͷDynamoDBςʔϒϧԽ 16
CSVͷDynamoDBςʔϒϧԽ • S3ʹΞοϓϩʔυ͞ΕͨCSVϑΝΠϧΛ DynamoDBςʔϒϧʹॻ͖ࠐΉFunction • FunctionΛ࣮ߦ͢ΔFunctionͰಉ࣮࣌ߦΛ ੍ޚ 17 #cmdevio2016 #La
CSVͷDynamoDBςʔϒϧԽ 18 #cmdevio2016 #La
CSVͷDynamoDBςʔϒϧԽ • ͱΞϓϦͷػೳͱͯ͠ߟ͍͑ͯͨ • ࣌ؒͷ͔͔ΔॲཧͩͬͨͷͰLambdaԽ • workerͰྑ͔͕ͬͨLambdaͷํ͕ ӡ༻͠ͳͯ͘ྑ͍ͿΜָ 19 #cmdevio2016
#La
ϞόΠϧΞϓϦ͔ΒݺͿAPI 20
ϞόΠϧΞϓϦ͔ΒݺͿAPI • APIαʔό͕୲͍ͬͯͨॲཧΛLambdaͰߦ͏ • DynamoDBʹॻ͖ࠐΉΑΓ༻్͕͍ • ϩδοΫΛޙ͔ΒมߋͰ͖Δ • ηΩϡϦςΟ্ͪΐͬͱ҆৺ 21
#cmdevio2016 #La
ϞόΠϧΞϓϦ͔ΒݺͿAPI 22 #cmdevio2016 #La
ϞόΠϧΞϓϦ͔ΒݺͿAPI 23 #cmdevio2016 #La
ϞόΠϧΞϓϦ͔ΒݺͿAPI • ݁ہɺཁ͕݅ᐆດͳஈ֊ͰLambda࠾༻Λ ܾஅͰ͖ͳ͔ͬͨ • APIαʔόΛNode.jsͰॻ͍ͯਐΊΔ • ཁ͕݅ݻ·ͬͨΓɺLambdaͷػೳ֦ு ΞΫηε͕ݟ௨ͤͨΒLambdaʹ͢Δ ͔͠Εͳ͍
24 #cmdevio2016 #La
σʔλͷऩू 25
σʔλͷऩू • KinesisʹLambdaͰσʔλΛS3ʹஷΊΔ • ஷΊͨσʔλόονͰRDSRedshift • PullܕͰىಈ͢ΔͷͰϨίʔυཧ͕ෆཁ • Lambdaͷػೳ֦ுͱڞʹมԽ 26
#cmdevio2016 #La
σʔλͷऩू 27 Firehoseొલ #cmdevio2016 #La
σʔλͷऩू 28 Firehoseొޙ #cmdevio2016 #La
CloudFormation 29
CloudFormation • https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/ template-custom-resources-lambda.html 30 #cmdevio2016 #La
Agenda • AWS Lambdaͱ࣮ • ࣮ͰͷϢʔεέʔε • LambdaͷTips • ࣮ʹΈࠐΉצॴ
31
όʔδϣχϯάͱΤΠϦΞε 32
όʔδϣχϯάͱΤΠϦΞε • όʔδϣϯ • ಉ͡FunctionͰ൛͝ͱʹมΘΔARN • ΤΠϦΞε • ඥͮ͘όʔδϣϯΛมߋͰ͖ΔARN •
͜ΕΒΛͬͯLambda FunctionΛཧ͢Δ 33 #cmdevio2016 #La
όʔδϣχϯάͱΤΠϦΞε 34 #cmdevio2016 #La
σϓϩΠ 35
σϓϩΠ • ϑΝΠϧΛzipͨ͠ΞϓϦέʔγϣϯόϯυϧ Λ࡞ͬͯΞοϓϩʔυ • Functionຊମ • ґଘϥΠϒϥϦ • aws-sdkaws-cliΛϥοϓ͢Δͱྑ͍
36 #cmdevio2016 #La
σϓϩΠ 37 σϓϩΠύοέʔδʹؚΊΔϥΠϒϥϦͷऔಘ #cmdevio2016 #La
σϓϩΠ 38 σϓϩΠύοέʔδͷΞοϓϩʔυ #cmdevio2016 #La
σϓϩΠ • ϚωδϝϯτίϯιʔϧͰΤΠϦΞεͷΓ ସ͑ 39 #cmdevio2016 #La
ࢹͱϦΧόϦ 40
ࢹͱϦΧόϦ • CloudWatchͰLambdaϝτϦΫεΛݟ͓ͯ͘ • ࣮ߦ݁Ռ͔Βҟৗ͕Θ͔Δͱϕετ • ҟৗ͕͋ͬͨΒϦτϥΠͰ͖ΔΑ͏ʹͯ͠ ͓͘ 41 #cmdevio2016
#La
ࢹͱϦΧόϦ • Lambdaࣗମ͕མͪͨ͜ͱແ͍ • ↑ݸਓͷײͰ͢ • ΞϓϦಉ༷ɺFunctionͷόά͔Βͷෆ۩߹ • ྫ֎Λर͑ͯͳ͔ͬͨɺͳͲ •
࣮ߦ݁Ռ͔Βෆ۩߹Λݕ • ࣄલʹܾΊͨ௨ΓͷϦτϥΠͰରԠ 42 #cmdevio2016 #La
Ϧϛοτ 43
Ϧϛοτ • http://docs.aws.amazon.com/ja_jp/lambda/ latest/dg/limits.html • ࣮༻্ϝϞϦͱಉ࣮࣌ߦͱαΠζʹҙ • ಉظݺͼग़͠ௐ͞ΕΔͱΤϥʔ͕ฦΔ 44 #cmdevio2016
#La
LambdaόοΫΤϯυͷฒྻੑ 45
LambdaόοΫΤϯυͷฒྻੑ • Functionɺฒྻͤ͞ΒΕΔΑ͏ʹॻ͘લఏ • Lambdaࣗମྑ͍͕ɺόοΫΤϯυ͕ͦΕʹ ͑ΒΕͳ͍Մೳੑ͕͋Δ 46 #cmdevio2016 #La
LambdaόοΫΤϯυͷฒྻੑ • ରࡦ1: εέʔϥϒϧͳόοΫΤϯυΛ͏ • DynamoDB • ରࡦ2: ฒྻΛ੍ޚ͢ΔΈΛೖΕΔ •
FunctionΛىಈ͢ΔFunctionΛઃ͚Δ 47 #cmdevio2016 #La
Lambdaͷඅ༻ 48
Lambdaͷඅ༻ • Lambdaࣗମ֨҆ͩ͠ɺແྉ͕େ͖͍ • AWSτʔλϧͰͷࢼࢉΛ͓͖ͯ͘͠ • ࣮ࡍͷෛՙΛ͔͚ͯྉۚͷ্͕ΓํΛݟΔ 49 #cmdevio2016 #La
Lambdaͷඅ༻ • CloudWatch Logsͷ߹ • FunctionͰඪ४ग़ྗͨ͠༰͕Logsʹ อଘ͞Εͯɺͦ͜Ͱͷ՝͕ۚൃੜ͢Δ • DynamoDBͷ߹ •
ΩϟύγςΟ͑Λ͙߹ଟΊʹઃఆ ͢Δඞཁ͕͋Γɺͦ͜Ͱ՝͕ۚൃੜ͢Δ 50 #cmdevio2016 #La
Agenda • AWS Lambdaͱ࣮ • ࣮ͰͷϢʔεέʔε • LambdaͷTips • ࣮ʹΈࠐΉצॴ
51
ͲͷॲཧΛLambdaʹ͢Δ͔ 52
Lambdaʹ͢Δॲཧ • ϏδωεϩδοΫҎ֎Λସ͢Δ߹ • ϏδωεϩδοΫΛସ͢Δ߹ • ӡ༻ิॿͰ͏߹ • ఘΊΔ߹ 53
#cmdevio2016 #La
ϏδωεϩδοΫҎ֎Λସ͢Δ߹ • αϜωΠϧ࡞ɺϑΥʔϚοτมͳͲ • ΞϓϦέʔγϣϯͷҡ࣋ʹෆՄܽͳػೳ • LambdaԽ͍͢͠ॲཧ • LambdaԽͷԸܙΛड͚͍͢ 54
#cmdevio2016 #La
ϏδωεϩδοΫΛସ͢Δ߹ • ैདྷAPIαʔό͕ߦ͍ͬͯͨॲཧΛସ͢Δ • Ұ൪ߴίετͳ෦͕ղܾ͢Δ • ཁ݅ʹΑ͔ͬͯͬͨ͠Γ͢Δ • CognitoAPIGWΛซ༻͢Δ 55
#cmdevio2016 #La
ӡ༻ิॿͰ͏߹ • CloudFormationͷΧελϜϦιʔεɺcronͷ ସͳͲ • ෆ۩߹࣌ൺֱతΧόʔ͍͢͠ͷͰಋೖ͠ ͍͔͢͠Εͳ͍ 56 #cmdevio2016 #La
ఘΊΔ߹ • ࣮ͰϏδωεͷޭ͕༏ઌ͞ΕΔ͜ͱ͕ଟ͍ • ແཧʹ͓͏ͱ͠ͳ͍ • Lambdaʹͩ͜ΘͬͯϏδωε͕ࣦഊͨ͠Β • ຊస •
ఫୀ͢Δͱ͖ʹLambdaԽͷ༨Λ͢ • LambdaରԠݴޠͰബ͍APIαʔό • όοΫΤϯυʹDynamoDB 57 #cmdevio2016 #La
ͲͷॲཧΛLambdaԽ͢Δ͔ • ӡ༻ิॿ͔ΒॳΊͯɺϏδωεϩδοΫҎ֎ ͷସΛࢦ͢ͷ͕ྑͦ͞͏ • ΞϓϦͷସͱͯ͠͏ͷෑډ͕ߴ͍ • Ϗδωεߟྀ͢Δͱঘྑ͠ 58 #cmdevio2016
#La
ෆ҆ʹඋ͑Δ 59
ෆ҆ʹඋ͑Δ • ࣦഊΛϋϯυϦϯάͰ͖Δͱ͜ΖͰߦ͏ • ӡ༻ٕज़ͷηΧϯμϦ • ࠷ॳLambdaͷସखஈΛߟ͓͑ͯ͘ • ࢹͱτϥϒϧ࣌ͷ෮چखஈΛΕͳ͍ 60
#cmdevio2016 #La
61 44 44 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ classmethod.jp
62 45 45 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ ͋Β͔͡ΊσʔλςʔϒϧΛ࡞͠ VTFS@JE
OBNF TDPSF EBUB XSJUFશৼΓ classmethod.jp
63 46 46 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ ॲཧྔ $47ϑΝΠϧͷߦ
ΛಡΈࠐΈ VTFS@JE OBNF TDPSF EBUB XSJUFશৼΓ classmethod.jp
64 47 47 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF ཧςʔϒϧʹ ૯Λొ͓ͯ͘͠ EBUB XSJUFશৼΓ classmethod.jp
65 48 48 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF BCDE σʔλΛ֨ೲͨ͠Β EBUB XSJUFશৼΓ classmethod.jp
66 49 49 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF BCDE ΧϯλΛՃࢉ ΞτϛοΫΧϯλ EBUB XSJUFશৼΓ classmethod.jp
67 50 50 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF BCDE FGHI σʔλΛ֨ೲͨ͠Β EBUB XSJUFશৼΓ classmethod.jp
68 51 51 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF BCDE FGHI ΧϯλΛՃࢉ ΞτϛοΫΧϯλ EBUB XSJUFશৼΓ classmethod.jp
69 52 52 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF BCDE FGHI શͯͷޭΛ֬ೝͨ͠Β EBUB XSJUFશৼΓ classmethod.jp
70 53 53 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF BCDE FGHI SFBEશৼΓʹ͢Δ EBUB SFBEશৼΓ classmethod.jp
71 55 55 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF BCDE ࣦ͠ഊͨ͠Β EBUB XSJUFશৼΓ '"*-&% 9 classmethod.jp
72 56 56 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF BCDE Ұக͠ͳ͍ͷͰ EBUB XSJUFશৼΓ 㱠 '"*-&% classmethod.jp
73 57 57 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
EBUB શͯ࡞Γ͢ VTFS@JE OBNF TDPSF EBUB XSJUFશৼΓ classmethod.jp
มԽʹඋ͑Δ 74
LambdaػೳՃͷྺ࢙ • 2015/04/09 Ұൠެ։ • 2015/05/28 σϓϩΠύοέʔδͷS3ରԠ • 2015/06/15 JavaରԠ
• 2015/07/09 APIGWରԠ • 2015/07/14 DynamoDB StreamsҰൠެ։ • 2015/10/08 Pythonɺόʔδϣϯɺ5ɺcron • 2016/02/11 VPCରԠ 75 http://aws.amazon.com/releasenotes/AWS-Lambda?browse=1 #cmdevio2016 #La
มԽʹඋ͑Δ • LambdaͷػೳՃεϐʔυ͍ • ৽ػೳͰطଘΞϓϦΛLambdaʹ Γग़ͨ͠ΓɺLambdaΛݮΒ͠ଓ͚Δ • ΞϓϦຊମͷςετྑ͍ઃܭΛҡ࣋͢Δ 76 #cmdevio2016
#La
77 Before After #cmdevio2016 #La
·ͱΊ 78
·ͱΊ • ͱΓ࣮͋͑ͣʹऔΓೖΕͯΈΑ͏ • ϏδωεΛՃͤ͞Δ͍ํΛ͠Α͏ • ͜ͷձͰ૬ஊ͠Α͏ • 3FΞʔΩςΫςΟϯά •
3F͓Έ૬ஊࣨ • ࠙ձ 79 #cmdevio2016 #La
80
None