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
Amazon CloudWatch Network Monitor のススメ
yuki_ink
1
200
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
150
強いチームと開発生産性
onk
PRO
33
11k
Platform Engineering for Software Developers and Architects
syntasso
1
510
スクラム成熟度セルフチェックツールを作って得た学びとその活用法
coincheck_recruit
1
140
AIチャットボット開発への生成AI活用
ryomrt
0
170
障害対応指揮の意思決定と情報共有における価値観 / Waroom Meetup #2
arthur1
5
470
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
[FOSS4G 2019 Niigata] AIによる効率的危険斜面抽出システムの開発について
nssv
0
310
100 名超が参加した日経グループ横断の競技型 AWS 学習イベント「Nikkei Group AWS GameDay」の紹介/mediajaws202411
nikkei_engineer_recruiting
1
170
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
170
【Startup CTO of the Year 2024 / Audience Award】アセンド取締役CTO 丹羽健
niwatakeru
0
950
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
The Invisible Side of Design
smashingmag
298
50k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Designing for Performance
lara
604
68k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
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