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 CDKでまるっと インフラ環境をIaCしたぞ!
Search
kubotak
September 24, 2022
Programming
0
410
AWS CDKでまるっと インフラ環境をIaCしたぞ!
PHPConference2022 ゴールドスポンサーLT 2022/09/24
kubotak
September 24, 2022
Tweet
Share
More Decks by kubotak
See All by kubotak
情報漏洩させないための設計
kubotak
0
87
Svelteコンポーネントの依存関係に秩序を〜
kubotak
0
74
DMARCレポート可視化ツールを SvelteKitで作った話
kubotak
2
460
Superforms本番投入で分かった良さとハマりどころ
kubotak
0
680
Storybookを書くだけでリグレッションテストが 実行される世界へようこそ
kubotak
31
10k
(うまくいった||いかなかった) 技術選定は何を考えていたか
kubotak
1
1.1k
ウォーターフォールに思えたプロジェクトにあったアジャイルの要素
kubotak
2
710
Felteで作る簡単フォームバリデーション
kubotak
1
1.4k
SvelteKitを本番投入してみて
kubotak
2
1.9k
Other Decks in Programming
See All in Programming
42 best practices for Symfony, a decade later
tucksaun
1
180
선언형 UI에서의 상태관리
l2hyunwoo
0
160
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
130
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
Go の GC の不得意な部分を克服したい
taiyow
2
780
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
250
Mermaid x AST x 生成AI = コードとドキュメントの完全同期への道
shibuyamizuho
0
160
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
770
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
130
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
200
Jakarta EE meets AI
ivargrimstad
0
240
バグを見つけた?それAppleに直してもらおう!
uetyo
0
180
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
A better future with KSS
kneath
238
17k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
It's Worth the Effort
3n
183
28k
A Modern Web Designer's Workflow
chriscoyier
693
190k
A Tale of Four Properties
chriscoyier
157
23k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
Docker and Python
trallard
42
3.1k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Transcript
Copyright© M&AΫϥυ AWS CDKͰ·Δͬͱ ΠϯϑϥڥΛIaCͨͧ͠ʂ PHP Conference Japan 2022 /
Kenjiro Kubota
Copyright© M&AΫϥυ ͓ͳ͡ΈɺM&AΫϥυͰ͢ PHPConferenceͱ͍͑M&AΫϥυ ※ࣾઆɺॾઆ͋Γ·͢ • PHPConference 2020(4໊) • PHPConference
2021(5໊) • PHPConference 2022(4໊) M&AΫϥυࡏ੶ΤϯδχΞͷPHPConferenceొஃྺ
Copyright© M&AΫϥυ ٻਓࠂαΠτͷΑ͏ͳM&AμΠϨΫτϚονϯά 3 ങ͍ख ɾҊ݅ใुM&AޭใुͷΈ ɾ࠷खྉͳ͠ ɾചΓखιʔγϯάͷνϟωϧ͕૿͑Δ ɾM&AχʔζΛൃ৴͢Δ͚ͩͰചΓखΛू٬ ɾհۀऀΛհͣ͞ʹμΠϨΫτʹΓऔΓՄೳ
ɾજࡏʹϦʔν͕Մೳ खྉແ ྉ ※ϓϥοτϑΥʔϜҊ݅ͷ߹ ※ ചΓख 1.ܝࡌ͢Δ ɾങ͍खͷM&AχʔζΛࣗΒௐΔ͜ͱ͕Մೳ ɾհۀऀΛհͣ͞ʹμΠϨΫτʹΓऔΓՄೳ ɾങ͍खͷM&A୲ऀʹίϯλΫτΛͱΕΔ ɾհۀऀΛΘͳ͍ͷͰखྉ͕ແྉ 2.ΦϑΝʔ͢Δ M&Aɾग़ࢿχʔζΛܝࡌ ങ͍खͷϝϦοτ ചΓखͷϝϦοτ ɾհۀऀΛΘͳ͍ͷͰखྉ͕ແྉ ʓʓྖҬͷձࣾΛ ืू͠·͢ ͜ͷձࣾͱҰॹʹ ͍͖͍ͬͯͨʂ 3 PR
Copyright© M&AΫϥυ ࢿۚௐୡϓϥοτϑΥʔϜ 2022ౙఏڙ։࢝ PR ࡢࠓͷࢿۚௐୡχʔζٸ૿ʹ͋ΘͤɺैདྷM&AΫϥυͰఏڙ͍ͯͨ͠ ʮࢿۚௐୡͷػೳʯΛΓग़͠ɺࢿۚௐୡʹಛԽͨ͠৽αʔϏεΛߏஙதͰ͢ɻ ͜ΕʹΑΓɺຊதͷελʔτΞοϓاۀͷࢿۚௐୡΛεϜʔζʹ͠ɺΑΓεϐʔυ ײΛ࣋ͬͨࣄۀʹߩݙͯ͠·͍Γ·͢ɻ
Copyright© M&AΫϥυ AWS CDKͱ
Copyright© M&AΫϥυ AWS CDKͱ AWS Cloud Development Kit (AWS CDK)
AWS CloudFormationΛ࣮ߦ͢ΔίʔυΛએݴతͳςϯϓϨʔτͱͯ͠ఆٛ͢Δ͜ͱͰϓϩϏ δϣχϯάΛ࣮ݱͰ͖ΔϑϨʔϜϫʔΫ CloudFormationʹΑΓIaC͕࣮ߦ͞ΕΔͷͰࣗಈϩʔϧόοΫυϦϑτݕग़ʢखಈมߋͯ͠͠ ·ͬͨ߹ʹఆٛͱ࣮ମ͕ဃ͢Δ͜ͱΛݕग़ʣ͕Ͱ͖Δɻ ҎԼͷݴޠ͕αϙʔτ͞Ε͍ͯΔ PHPͳ͍
Copyright© M&AΫϥυ AWS CDKͱ AWS CDK Constructs CDKAPPɺStackɺConstructͷ֤ཁૉʹΑͬͯߏ͞Ε͍ͯΔɻ • APP
◦ Stackͷґଘؔͷఆٛ • Stack ◦ CloudformationͷStack୯Ґ ◦ σϓϩΠͷ࠷খ୯Ґ • Construct ◦ AWSͷϦιʔε
Copyright© M&AΫϥυ AWS CDKͱ Construct Library CDKConstruct LibraryΛ༻ͯ͠AWSϦιʔεΛఆٛ͠·͢ɻ Construct LibraryʹҎԼͷ3छྨʹ͚ΒΕ·͢ɻ
• low-level constructsʢL1ʣ ◦ ײతʹϦιʔεΛఆٛ͢Δ͜ͱ͕Ͱ͖ɺσϑΥϧτ͕ઃఆࡁΈͷศརͳϝιου ͕ఏڙ͞ΕΔ • higher-level, intent-based APIʢL2ʣ ◦ ϓϩύςΟΛ໌ࣔతʹઃఆ͢Δඞཁ͕͋ΔͨΊɺύϥϝʔλΛৄࡉʹઃఆͰ͖Δ ◦ Ϋϥε໊ʹCfnϓϨϑΟοΫε͕͍͍ͭͯΔ • patternsʢL3ʣ ◦ ҰൠతͳΞʔΩςΫνϟύλʔϯʹै͏ߴϨϕϧͷConstructΛఏڙ
Copyright© M&AΫϥυ AWS CDKͱ AWS SDKʹ͍ͭͯৄ͘͠Γ͍ͨํ ͪ͜ΒͷηογϣϯΛνΣοΫʂ ʢ͢ͰʹऴΘ͍ͬͯΔηογϣϯͳͷͰεϥΠυ͔ಈըΛࢀর͍ͩ͘͞ʣ
Copyright© M&AΫϥυ M&AΫϥυͷࣄྫ M&AΫϥυͷΠϯϑϥ Amazon Web Service(AWS)্Ͱߏங͍ͯ͠·͢ɻ ओʹҎԼͷαʔϏεΛར༻ • ECS(Fargate)
• ECR • Lambda • Cloudfront • Open Search Service • ALB • CloudWatch • Athena • S3 • RDS • ElastiCache • SQS • etc
Copyright© M&AΫϥυ AWS CDKΛಋೖ͢Δલ ϒϥβͷAWSίϯιʔϧ͔Βૢ࡞ αʔϏεΠϯ͔Β3ఔ࣮͜ͷঢ়ଶͰಛʹʹͳͬͯͳ͔ͬͨɻ ࡞ۀΛεΫγϣͯ͠υΩϡϝϯτʹ͢ͳͲߦ͍ͬͯͯΘ͕͋ͬͨ͠͞ɺසൟʹΠϯϑϥʹ खΛೖΕΔ͜ͱ͕ͳ͔ͬͨɻ Ұ෦Serverless FrameworkΛ͏ͳͲIaCʹͳ͍ͬͯΔͷ͋ͬͨɻ
Copyright© M&AΫϥυ ֬ೝڥΛ૿ͦ͏
Copyright© M&AΫϥυ ։ൃऀ͕૿͑ɺνʔϜΛ͚ͨ νʔϜ͕͔Εͨ͜ͱʹΑΓ֬ೝڥʢ͍ΘΏΔεςʔδڥʣͰಈ࡞֬ೝ͍ͨ͠λΠϛ ϯά͕ҟͳΓσϓϩΠौ͕ൃੜͨ͠ɻ ͦͷͨΊɺ֬ೝڥΛෳ࡞Δ͜ͱʹɾɾɾ
Copyright© M&AΫϥυ ෳڥ࡞Δࡍͷো
Copyright© M&AΫϥυ εϖοΫΛ͋Θͤͯෳڥ࡞Δखؒ ϒϥβίϯιʔϧ͔ΒڥΛ࡞Δͷ͕ඇৗʹखؒ কདྷతʹ͞ΒʹνʔϜ͕૿͑ͨ߹ɺ·ͨಉ͡Λͬͯ࡞Δख͕ؒൃੜ͢Δ ͞ΒʹฐࣾͰCloudfrontͷBehaviorΛར༻ͯ͠ύε͝ͱʹ ΞϓϦέʔγϣϯͷ͖ઌΛมߋ͢Δॲཧ͕େྔʹ͋ͬͨɻ ڥΛෳ࡞Δࡍʹͱͯͭͳ͍࡞ۀ֬ೝ͕ඞཁʹͳΔɻ
Copyright© M&AΫϥυ ͦ͜ͰɺAWS CDK
Copyright© M&AΫϥυ AWS CDKΛར༻ͯ͠ڥߏங Stack୯ҐͰڞ௨Խ͠ɺڥʹΑͬͯҟͳΔมΛ༩͑Δ͜ͱͰεϖοΫ֤छIPΞυϨε ͷมಈ͕Ͱ͖ΔΑ͏ʹߏங CloudfrontͷBehaviorྻͰอ࣋͠ɺCDK͔ΒҰׅͰө͞ΕΔΑ͏ʹରԠ ෳڥ·ͱΊͯಉ͡BehaviorΛઃఆ͢Δ͜ͱ͕Ͱ͖ΔΑ͏ʹͳͬͨɻ
Copyright© M&AΫϥυ ͪΐͬͱ೦ͳͱ͜Ζ
Copyright© M&AΫϥυ AWS CDKΛར༻ͯ͠ݟ͑ͨ՝ • CloudFromation͕࣮ߦ͞ΕΔͨΊɺྃ·Ͱ݁ߏ͕͔͔࣌ؒΔɻ ◦ ಛʹCloudfront֤Edgeαʔόʔͷө·Ͱ͍ͬͯΔײ͡ʁͰ͍ • Fargate
SpotΛ͏ͨΊʹL1 ConstructͰ͏·͘ߦ͔ͳ͔ͬͨͷͰL2ʹΑΔCfnΫϥ εΛ͏ඞཁ͕͋ͬͨɻͦͷଞʹ݁ہCfnΫϥεͰॻ͔ͳ͍ͱࢦఆͰ͖ͳ͍ͷ͕ଟ͔ͬ ͨ • ϥΠϒϥϦ͕TypeScriptͷݴޠͷྑ͞Λ͍Ε͍ͯͳ͍ ◦ ܾ·ͬͨจࣈ͔͑͠ͳ͍ͳΒUnionͰఆٛͯ͠΄͍͠ɻStringʹͳ͍ͬͯΔͷͰɺ ͳʹ͕ࢦఆͰ͖Δ͔Θ͔Βͳ͍ͷ͕݁ߏ͋Δʢ݁ہެࣜυΩϡϝϯτΛݟͳ͚Ε ͑ͳ͍ʣ • CDKͷίʔυͨͩཏྻ͢Δ͚ͩͰͳ͘StackConstruct୯ҐΛ͏·͘ઃܭ͢Δඞཁ͕ ͋Δͱײͨ͡
Copyright© M&AΫϥυ ·ͱΊ • Թ͔Έͷ͋Δख࡞ۀ͔ΒIaCʹҠߦͨ͜͠ͱͰࠓޙڥ͕૿͑ͯఆٛΛ΄΅ίϐϖ Ͱ૿͚ͩ͢Ͱྑ͍Ϩϕϧʹͳͬͨʂ • CloudfrontͷBehaviorͣͬͱ՝ײ͕͕͋ͬͨCDKͰεοΩϦͨ͠ • ୀ۶ͳ͜ͱCDKʹΒͤΑ͏ɻ
Copyright© M&AΫϥυ Thanks for watching this :)