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
月額10円から作るServerLess Website
Search
Kunihiro Morita
March 21, 2016
Technology
47
19k
月額10円から作るServerLess Website
JAWS-UG福岡 2016/3/21「また濃い目にAWSの話をしてみよう」でお話した資料です。
Kunihiro Morita
March 21, 2016
Tweet
Share
More Decks by Kunihiro Morita
See All by Kunihiro Morita
絵で覚える AWS 全 (?) サービス入門 〜 できるAWSカルタ 〜/jawsug-20191019
morita92hiro
1
2.3k
決戦用MSセンチネル/alterbooth-20190606
morita92hiro
1
240
勝手にAlibaba Cloud White Beltシリーズ Elastic Compute Service(ECS)/alieaters-20190301
morita92hiro
0
390
夏休みで差がつく!Ansible/ansiblejp-20180803
morita92hiro
2
2.6k
希望のRancher〜コンテナをアウフヘーベン〜/ranchermeetup-20171006
morita92hiro
0
270
いまからDockerで始めるGitLab CE/gitlabjp-20170919
morita92hiro
1
1.3k
月額10円から作るServerless Website〜Azure編〜/serverlessfukuoka-20170825
morita92hiro
8
16k
コンテナ運用いきのこるには/ranchermeetup-20170807
morita92hiro
1
560
AWS Summit Tokyoをお探しですか?/jawsug-20170713
morita92hiro
0
160
Other Decks in Technology
See All in Technology
AWS Lambda のトラブルシュートをしていて思うこと
kazzpapa3
2
180
【令和最新版】AWS Direct Connectと愉快なGWたちのおさらい
minorun365
PRO
5
760
AGIについてChatGPTに聞いてみた
blueb
0
130
OCI Network Firewall 概要
oracle4engineer
PRO
0
4.2k
OCI Security サービス 概要
oracle4engineer
PRO
0
6.5k
適材適所の技術選定 〜GraphQL・REST API・tRPC〜 / Optimal Technology Selection
kakehashi
1
700
Platform Engineering for Software Developers and Architects
syntasso
1
520
AI前提のサービス運用ってなんだろう?
ryuichi1208
8
1.4k
プロダクト活用度で見えた真実 ホリゾンタルSaaSでの顧客解像度の高め方
tadaken3
0
190
アジャイルでの品質の進化 Agile in Motion vol.1/20241118 Hiroyuki Sato
shift_evolve
0
170
DynamoDB でスロットリングが発生したとき_大盛りver/when_throttling_occurs_in_dynamodb_long
emiki
1
430
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
130
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
31
6.3k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
A Philosophy of Restraint
colly
203
16k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
900
Unsuck your backbone
ammeep
668
57k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Done Done
chrislema
181
16k
Transcript
ֹ݄10ԁ͔Β࡞Δ ServerLess Website 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 1
ాɹ༟ @morita92hiro kunihiro.morita.52 - ܦྺ - ΈࠐΈΤϯδχΞ - ΅ͬͪΠϯϑϥΤϯδχΞ 2013ʙ
2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 2
ʮ1܅ɺLPαΠτ࡞ͬ ͯɻCMS͍Βͳ͍ɻʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 3
>>1ʮS3ͷग़൪ʂʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 4
Static Website Hosting • ͙͢࡞ΔΕͯ(10ఔ) • ҆ͯ͘(ֹ݄10ԁʙ) • ݎ࿚(99.999999999%) 2016/3/21
JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 5
ʮ1܅ɺ͓͍߹Θͤϖʔδ࡞ͬͯʯ >>1 ʮS3੩త͔͠ɾɾɾʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 6
ʮ1܅ɺ͓͍߹Θͤʯ >>1 ʮ͍ɾɾɾʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 7
>>1ʮJSͰS3ʹPUT͓͍ͯ͠߹Θͤ σʔλஔ͍ͯɺʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 8
>>1ʮJS͕S3ͷॻ͖ࠐΈݖݶඞཁ ͠ɺJSʹೝূใॻ͖ࠐΉͷ ɾɾɾʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 9
>>1ʮͤʂCognito͕ ͋ΔΜʂʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 10
ະೝূήετʹॻ͖ࠐΈݖݶ • IAMͰCognitoʹS3ͷॻ͖ࠐΈݖݶΛ༩ • JSCognito͔ΒҰ࣌తͳAWSೝূใऔಘ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 11
// Cognito AWS.config.region = 'ap-northeast-1'; // Region AWS.config.credentials = new
AWS.CognitoIdentityCredentials({ IdentityPoolId: 'ap-northeast-1:12345679-1234-1234-1234-123456789012', }); AWS.config.credentials.get(); // S3 Put var s3 = new AWS.S3({ params: { Bucket: bucket } }); s3.putObject({ Key: now.getTime() + '.json', ContentType: 'application/json', Body: blob }, function(err, data) { if (data !== null) { alert('Success'); } else { alert('Fail'); } } ); 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 12
ิ • ͓͍߹Θͤσʔλஔ͖ͷS3όέοτʹCORSઃఆ • S3 PUT߈ܸ͞Εͨ͘ͳ͍ͷͰ͔ͬ͠Γ੍ݶ <?xml version="1.0" encoding="UTF-8"?> <CORSConfiguration
xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <CORSRule> <AllowedOrigin>http://hoge.com</AllowedOrigin> <AllowedMethod>PUT</AllowedMethod> <AllowedHeader>*</AllowedHeader> </CORSRule> </CORSConfiguration> 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 13
>>1ʮ͓͍߹ΘͤΛͲ͏ͬͯΖ͏͔ɾɾɾʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 14
>>1ʮͤʂLambda͕ ͋ΔΜʂʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 15
LambdaͰαʔόʔϨεʹϝʔϧૹ৴ • S3ϑΝΠϧՃΠϕϯτΛτϦΨʔʹLambdaΩοΫ • Lambda͔ΒSESͰϝʔϧૹ৴ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 16
>>1ʮϝʔϧ௨͚͚ͩͩͲɺޙ͔Β Ճ͘͢͠ɾɾɾʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 17
>>1ʮSNSڬΜͲ͚͍ ͍Ζʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 18
நతʹ • S3ΠϕϯτΛSNSܦ༝ͰLambdaΩοΫ • ΞΫγϣϯՃSNSαϒεΫϦϓγϣϯՃ͚ͩͰࡁΉ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 19
ʮ1܅ɺS3͍͠HTTP ͷΈɻ࣌HTTPSʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 20
>>1ʮCloudFrontͰര ʹͨ͠Δʂʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 21
CDN • ίϯςϯπσϦόϦʔαʔϏε • GzipѹॖػೳͰ͞Βʹߴɺసૹίετݮʂ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 22
ʮ1܅ɺαʔόʔূ໌ॻ͍҆ͷͰʯ >>1ʮɾɾɾʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 23
>>1ʮͤʂACM͕͋Δ Μʂʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 24
AWSͷແྉSSLূ໌ॻ • υϝΠϯೝূ(DV) • ରԠαʔϏεCloudFrontͱELB(us-east-1ͷΈ) 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 25
>>1ʮͳΜ͔߈ܸ͞Εͯ Δؾ͕͢ɾɾɾʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 26
ิ ̏ߦͰΞΫηεղੳ • S3, CloudFrontͷΞΫηεϩάS3ʹग़ྗՄೳ • ΞΫηεϩά͕S3PUT͞ΕͨτϦΨʔͰLambdaΩοΫ • Lambda͔ΒElasticsearchʹ์ΓࠐΜͰKibanaͰੳ 2016/3/21
JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 27
>>1ʮWAFͰϒϩοΫʂʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 28
WAF • ରԠαʔϏεCloudFrontͷΈ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 29
>>1ʮੲCloudFrontམͪͨɻ·ͨݺ ͼग़͞Εͨ͘ͳ͍ϯΰɾɾɾʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 30
>>1ʮRoute53ʹม͑Δʂʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 31
҆৺ͷSLA100%ͷDNS • DNSϔϧενΣοΫͰCloudFrontΛࢹ • ϔϧενΣοΫNGͰS3ʹDNSΓସ͑(ϑΣΠϧΦʔόʔ) 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 32
ʮ1܅ɺܞଳʹϝʔϧಧ͔ͳ͍Μͩʯ >>1ʮSESΩϟϦΞϝʔϧ͕͕ɾɾɾʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 33
>>1ʮSendGridʹมߋɻͰ LambdaʹೝূใΛຒΊࠐΈͨ͘ͳ ͍ϯΰɾɾɾʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 34
>>1ʮͤʂKMS͕͋Δ Μʂʯ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 35
҉߸ˍ෮߸ • KMSͰೝূใΛ҉߸Խͯ͠ຒΊࠐΈ • ͏ͱ͖ʹKMSͰ෮߸ɻLambdaʹ෮߸ͷIAM Role༩͑Δɻ 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 36
·ͱΊ • ֹ݄10ԁ͙Β͍ • ֹ݄1000ԁ͙Β͍?ɺWAFআ͚300ԁ͙Β͍? 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 37
σϞ (σϞΠϝʔδͰ͢) 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 38
͓ΘΓ! 2016/3/21 JAWS-UGԬ ·ͨೱ͍ʹAWSͷΛͯ͠ΈΑ͏ 39