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
250
勝手にAlibaba Cloud White Beltシリーズ Elastic Compute Service(ECS)/alieaters-20190301
morita92hiro
0
400
夏休みで差がつく!Ansible/ansiblejp-20180803
morita92hiro
2
2.6k
希望のRancher〜コンテナをアウフヘーベン〜/ranchermeetup-20171006
morita92hiro
0
280
いまからDockerで始めるGitLab CE/gitlabjp-20170919
morita92hiro
1
1.4k
月額10円から作るServerless Website〜Azure編〜/serverlessfukuoka-20170825
morita92hiro
8
17k
コンテナ運用いきのこるには/ranchermeetup-20170807
morita92hiro
1
570
AWS Summit Tokyoをお探しですか?/jawsug-20170713
morita92hiro
0
170
Other Decks in Technology
See All in Technology
日本版とグローバル版のモバイルアプリ統合の開発の裏側と今後の展望
miichan
1
130
How to be an AWS Community Builder | 君もAWS Community Builderになろう!〜2024 冬 CB募集直前対策編?!〜
coosuke
PRO
2
2.8k
OpenShift Virtualizationのネットワーク構成を真剣に考えてみた/OpenShift Virtualization's Network Configuration
tnk4on
0
130
Oracle Cloud Infrastructure:2024年12月度サービス・アップデート
oracle4engineer
PRO
0
170
Wantedly での Datadog 活用事例
bgpat
1
430
Amazon SageMaker Unified Studio(Preview)、Lakehouse と Amazon S3 Tables
ishikawa_satoru
0
150
マルチプロダクト開発の現場でAWS Security Hubを1年以上運用して得た教訓
muziyoshiz
2
2.2k
Snykで始めるセキュリティ担当者とSREと開発者が楽になる脆弱性対応 / Getting started with Snyk Vulnerability Response
yamaguchitk333
2
180
NW-JAWS #14 re:Invent 2024(予選落ち含)で 発表された推しアップデートについて
nagisa53
0
250
Storage Browser for Amazon S3
miu_crescent
1
140
KubeCon NA 2024 Recap / Running WebAssembly (Wasm) Workloads Side-by-Side with Container Workloads
z63d
1
240
AIのコンプラは何故しんどい?
shujisado
1
190
Featured
See All Featured
Building Your Own Lightsaber
phodgson
103
6.1k
Bash Introduction
62gerente
608
210k
The Cost Of JavaScript in 2023
addyosmani
45
7k
We Have a Design System, Now What?
morganepeng
51
7.3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Building an army of robots
kneath
302
44k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
How GitHub (no longer) Works
holman
311
140k
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