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
TerraformとCloudFormationどちらを採用すべき?
Search
Fukazawa Shun
May 19, 2021
Programming
0
19k
TerraformとCloudFormationどちらを採用すべき?
AKIBA.AWS ONLINE #03 -IaC を語りたい 編-
での登壇資料
Fukazawa Shun
May 19, 2021
Tweet
Share
More Decks by Fukazawa Shun
See All by Fukazawa Shun
AWS認定資格取得に向けた効果的なデベキャン活用法や学習方法について
fukazawashun
1
260
DevelopersIO BASECAMP(デベキャン)の今までとこれからについて
fukazawashun
0
350k
DevelopersIO BASECAMPで扱うサービスのアップデート紹介
fukazawashun
0
810
書く技術
fukazawashun
0
2.1k
GitHub Actionsを使ってAWS App Runnerにデプロイできるようになりました
fukazawashun
0
1.4k
Other Decks in Programming
See All in Programming
Zoneless Testing
rainerhahnekamp
0
120
バグを見つけた?それAppleに直してもらおう!
uetyo
0
160
Mermaid x AST x 生成AI = コードとドキュメントの完全同期への道
shibuyamizuho
0
160
CSC509 Lecture 14
javiergs
PRO
0
130
似たもの同士のPerlとPHP
uzulla
1
120
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
120
nekko cloudにおけるProxmox VE利用事例
irumaru
3
390
HTTP compression in PHP and Symfony apps
dunglas
2
1.6k
Jakarta EE meets AI
ivargrimstad
0
200
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
3
1.1k
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
Symfony Mapper Component
soyuka
2
690
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
95
5.2k
Thoughts on Productivity
jonyablonski
67
4.3k
Statistics for Hackers
jakevdp
796
220k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Visualization
eitanlees
145
15k
GitHub's CSS Performance
jonrohan
1030
460k
Building Applications with DynamoDB
mza
91
6.1k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
What's in a price? How to price your products and services
michaelherold
243
12k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.3k
Transcript
None
5FSSBGPSNͱ$MPVE'PSNBUJPO ͲͪΒΛ࠾༻͖͢ʁ ਂᖒ ढ़ʢ'VLB[BXB4IVOʣ "84ࣄۀຊ෦ίϯαϧςΟϯά෦
3 ⾃⼰紹介 ਂᖒ ढ़ʢFukazawa Shunʣ クラスメソッド株式会社 AWS事業本部コンサルティング部 @shun_quartet #AKIBAAWS
4 ϓϩϩʔά 5FSSBGPSN PS $MPVEGPSNBUJPO
5 جຊతͳબఆ݅ͱͯ͠ • ·ͣબఆʹ͓͚Δલఏͱͯ͠ʜ • ೲͱͯ͠ࢦఆ͕͋Δ͔ • ϝϯόʔͰϝϯςՄೳ͔ • ෳࡶͳͷɺ࠷ઌͳͷ͕ྑ͍ͷͰͳ͍
• ࠾༻ٕͨ͠ज़ͷಛੑΛνʔϜͰཧղ͠ӡ༻͍͚ͯ͠Δ͔
6 両者の違いって︖ 基本的な違い
7 $MPVEGPSNBUJPOʹ͍ͭͯ • "84͕ఏڙ • :BNM͔KTPOͰهड़ • "84্Ͱ࣮ߦ • *".ϩʔϧΛ༻ͨ͠ηΩϡΞͳೝূ
Ec2Instance: Type: AWS::EC2::Instance Properties: ImageId: Fn::FindInMap: - "RegionMap" - Ref: "AWS::Region" - "AMI"
8 5FSSBGPSNʹ͍ͭͯ • )BTIJ$PSQ͕ఏڙ • )$-Ͱهड़ • ϩʔΧϧ1$ͷϚγϯ্Ͱ࣮ߦ • ΩʔͷཧΛݕ౼͢Δඞཁ͕͋Δ
• &$ͷ"84αʔϏε্Ͱͷ࣮ߦεΠονϩʔϧ ͰηΩϡΞͳೝূ͕Մೳ resource "aws_instance" "web" { ami = data.aws_ami.ubuntu.id instance_type = "t3.micro" tags = { Name = "HelloWorld" } }
9 ྆ऀͷҧ͍ͬͯʁ ྆ऀͷ۩ମతͳ ಛΛݟ͍͖ͯ·͠ΐ͏ʂ
10 両者の違いって︖ 異なるリージョンへのデプロイ
11 ҟͳΔϦʔδϣϯͷσϓϩΠ • 4UBDL4FUT IUUQTEPDTBXTBNB[PODPNKB@KQ"84$MPVE'PSNBUJPOMBUFTU6TFS(VJEFTUBDLTFUTDPODFQUTIUNM • ҟͳΔϦʔδϣϯʹϦιʔεΛ࡞ߋ৽আ͢Δػೳ • ҟͳΔΞΧϯτʹσϓϩΠՄೳ Region
Region Region Stack sets stack stack stack アカウントA アカウントB
12 ҟͳΔϦʔδϣϯͷσϓϩΠ • ҟͳΔ1SPWJEFSΛ༻͍Δ IUUQTXXXUFSSBGPSNJPEPDTQSPWJEFSTJOEFYIUNM Region Region Region Provider A
Provider B Provider C provider aws { region = "ap-northeast-1” } provider aws { region = "us-east-1" alias = "use1" } resource "aws_instance" "web" { 〜〜〜 } resource "aws_instance" "web_use1" { provider = aws.use1 〜〜〜 }
13 ҟͳΔϦʔδϣϯͷσϓϩΠ • "84Ͱͷ*B$Ͱ͋Ε$MPVEGPSNBUJPOͷํ͕ҟͳΔϦʔ δϣϯ ΞΧϯτʹσϓϩΠ͍͢͠ • ϚϧνϦʔδϣϯγεςϜͰͳͯ͘ηΩϡϦςΟͷ߹Ͱ"84$POGJH"NB[PO (VBSE%VUZΛશͯͷϦʔδϣϯʹల։͍ͨ͠ͱ͍ͬͨधཁʹରԠ͍͢͠ •
5FSSBGPSN1SPWJEFSΛΓସ͑Δ͜ͱ͕Ͱ͖ΔނͷϝϦοτɻ
14 異なるIaaSへのデプロイ 異なるIaaSへのデプロイ
15 ҟͳΔ*BB4ͷσϓϩΠ • $MPVEGPSNBUJPO"84ͷαʔϏεͷͨΊଞͷϓ ϥοτϑΥʔϜͷσϓϩΠରԠ͍ͯ͠ͳ͍ • 5FSSBGPSN1SPWJEFSΛΓସ͑Δ͜ͱͰҟͳΔ *BB4ʹσϓϩΠ͕ߦ͑Δ • "84
• ($1 • "[VSF ʜ
16 差分検出 差分検出
17 ࠩݕग़ • *B$Ͱཧ͍ͯ͠Δͷͷɺ͍ͭख࡞ۀͰڥΛमਖ਼ ͯ͠͠·͏͜ͱΑ͋͘Δ • ڥͱίʔυ͕ဃͯ͠͠·ͬͨࡍͷݕग़ͲͷΑ͏ʹߦ͏͔ʁ
18 ࠩݕग़ • $MPVEGPSNBUJPOͷ߹ɺυϦϑτݕग़ͱ͍͏ػೳ͕͋Δ IUUQTEPDTBXTBNB[PODPNKB@KQ"84$MPVE'PSNBUJPOMBUFTU6TFS(VJEFEFUFDUESJGUTUBDLIUNM • ڥͱίʔυͷဃΛࣗಈͰݕग़͢Δػೳ • $POGJHϧʔϧͱΈ߹ΘͤͨΓͯ͠௨Մೳ Stack
VPC NAT gateway Instance Instance ≒ AWS Config EventBridge
19 ࠩݕग़ • 5FSSBGPSNͷ߹ɺ1MBOίϚϯυΛ࣮ߦͯ͠4UBUFͱͷࠩ Λൺֱ͢Δ IUUQTXXXUFSSBGPSNJPEPDTDMJDPNNBOETQMBOIUNM • ΦϓγϣϯΛ͚Δ͜ͱͰίʔϧόοΫ͔Βࠩͷݕग़͕Մೳ VPC NAT
gateway Instance Instance ≒ $ terraform plan -detailed-exitcode
20 ࠩݕग़ • 5FSSBGPSNͷ߹ɺࣗಈԽ͍ͨ͠߹࡞ΓࠐΈ͕ඞཁʹͳΔ • $MPVEGPSNBUJPOͩͱࠩݕग़"84ͷϚωʔδυαʔϏε ʹدͤΔ͜ͱ͕Ͱ͖Δ
21 両者の違いって︖ ロジック
22 ϩδοΫ • ಉ͡ϦιʔεΛෳ࡞͍ͨ͠߹ɺΓมʹΑͬͯΞ ΫγϣϯΛม͍͑ͨέʔε͋Δ • ྫɿ มʹ֨ೲ͞Ε͍ͯΔ";͚ͩ4VCOFUΛ࡞͍ͨ͠ • ϩδοΫͷ࣮ͲͷΑ͏ʹߦ͏͔
23 ϩδοΫ • $MPVEGPSNBUJPOͷ߹ • $POEJUJPOTηΫγϣϯΛ༻͢Δ • ༻Մೳͳؔ • 'O"OE
• 'O&RVBMT • 'O*G • 'O/PU • 'O0S Description: "Template.” Parameters: EnvType: Type: String AllowedValues: - prod - test Conditions: CreateProdResources: !Equals - !Ref EnvType - prod Resources: 〜〜〜 Outputs: 〜〜〜
24 ϩδοΫ • 5FSSBGPSNͷ߹ • ߏମΛ༻͍ͨ܁Γฦ͠ॲཧ • ࡾ߲ԋࢉࢠ • ΈࠐΈؔ
• ͍ΘΏΔϓϩάϥϜݴޠʹ ͍ۙهड़ • ذॲཧͳ͍ dynamic "origin_group" { for_each = var.load_balancer_origin_groups content { name = origin_group.key dynamic "origin" { for_each = origin_group.value.origins content { hostname = origin.value.hostname } } } } variable "load_balancer_origin_groups" { type = map(object({ origins = set(object({ hostname = string })) })) }
25 排他制御 排他制御
26 ഉଞ੍ޚ • ಉ࣮࣌ߦ͞Εͨ࣌ʹ4UBDLPS4UBUF্͕ॻ͖͞Εͯ͠·͏͜ͱ ͳ͍ͷ͔ʁ • ෳਓͰӡ༻͍ͯ͠ΔࡍʹॏཁͳϙΠϯτɻɻ
27 ഉଞ੍ޚ • $MPVEGPSNBUJPOͷ߹ • ࣮ߦத$3&"5&@*/@130(3&44εςʔλεʹͳΔ • $3&"5&@*/@130(3&44ͷ࠷தมߋෆՄ
28 ഉଞ੍ޚ • 5FSSBGPSNͷ߹ • 4UBUFΛͲ͜ʹஔ͘ͷ͔ʹΑͬͯҟͳΔ • IUUQTXXXUFSSBGPSNJPEPDTMBOHVBHFTFUUJOHTCBDLFOETJOEF YIUNM •
%ZOBNP%#MPDLΛ༻͍Δ͜ͱ͕Ͱ͖Εഉଞ੍ޚՄೳ • IUUQTXXXUFSSBGPSNJPEPDTMBOHVBHFTUBUFMPDLJOHIUNM
29 両者の違いって︖ バージョン管理
30 όʔδϣϯཧ • όʔδϣϯΛ͏·͘ཧ͢Δඞཁ͕͋Δ • ϝϯόʔͷ࣮ߦڥࠩҧ • ࠷৽ͷैͱݱߦҡ࣋
31 όʔδϣϯཧ • $MPVEGPSNBUJPOͷ߹ • "84ͷαʔϏεͳͷͰ͍ΘΏΔόʔδϣϯͷ֓೦͕ͳ͍ • ςϯϓϨʔτόʔδϣϯଘࡏ͢Δͷͷɺݱ࣌Ͱ͔͠ ͳ͍ͷͰόʔδϣϯཧͷඞཁ͕ͳ͍ •
IUUQTEPDTBXTBNB[PODPNKB@KQ"84$MPVE'PSNBUJPOMBUFTU6 TFS(VJEFGPSNBUWFSTJPOTUSVDUVSFIUNM
32 όʔδϣϯཧ • 5FSSBGPSNͷ߹ • 5FSSBGPSNͦͷͷͱ1SPWJEFSͷόʔδϣϯΛཧ͢Δ • 5FSSBGPSNͷόʔδϣϯUGFOWͰཧ • IUUQTHJUIVCDPNUGVUJMTUGFOW
• 1SPWJEFSSFRVJSFE@QSPWJEFSTͰࢦఆ • ࠷ۙUFSSBGPSNMPDLIDMͱ͍͏QSPWJEFSͷMPDLϑΝΠϧొ • IUUQTXXXUFSSBGPSNJPEPDTMBOHVBHFQSPWJEFSTSFRVJSFNFOUTIUNM • ͍ΘΏΔϓϩάϥϛϯάݴޠͷόʔδϣϯཧʹ͍ۙ
33 開発ツール 開発ツール
34 ։ൃπʔϧ • γϯλοΫεΤϥʔ։ൃஈ֊Ͱݕ͍ͨ͠ • σϓϩΠ͔ͯ͠ΒΤϥʔͩͱ໘ • *%&ʹΈࠐΊΔ։ൃิॿπʔϧ͋Δͷ͔ʁʁ
35 ։ൃπʔϧ • $MPVEGPSNBUJPO • $GOMJOU • IUUQTBXTBNB[PODPNKQCMPHTOFXTHJUQSFDPNNJUWBMJEBUJPOPGBXT DMPVEGPSNBUJPOUFNQMBUFTXJUIDGOMJOU •
ҎԼͷΑ͏ͳνΣοΫΛࣗಈͰͯ͘͠ΕΔ • ਖ਼͍͠ܗࣜʢ:BNM PS+TPOʣͰॻ͚͍ͯΔ͔ • όάͳ͍͔ʢଘࡏ͠ͳ͍มࢀরɺฦΓͷظʣ • ଞͷ࣮ํ๏ͷఏҊʢϋʔυίʔυͷճආʣ • *%&ʢ74$PEFʣͷϓϥάΠϯ͋Δ • IUUQTHJUIVCDPNBXTTDSJQUJOHHVZDGPSN74$PEF
36 ։ൃπʔϧ • 5FSSBGPSN • ίϚϯυΦϓγϣϯʹࣗಈิਖ਼ػೳ͕͋Δ • IUUQTXXXUFSSBGPSNJPEPDTDMJDPNNBOETGNUIUNM • อଘ࣌ʹ͜ͷίϚϯυΛ࣮ߦ͢ΕࣗಈͰߏจमਖ਼
• -JOUFSπʔϧଘࡏ • IUUQTHJUIVCDPNUFSSBGPSNMJOUFSTUGMJOU • ίʔυ͕ηΩϡϦςΟతʹͳ͍͔ΛνΣοΫ͢Δπʔϧ • ྫɿηΩϡϦςΟάϧʔϓ͕શ։Ͱઃఆ͞Ε͍ͯΔ • IUUQTHJUIVCDPNUGTFDUGTFD • *%&ͷϓϥάΠϯ͋Δ • 74$PEF 1Z$IBSN $ terraform fmt
37 まとめ まとめ
38 ·ͱΊ • $MPVEGPSNBUJPO • ෳࡶͳॲཧͷهड़͍͠ • ͋·Γෳࡶʹͯ͠͠·͏ͱݟʹ͘͘ͳΔ͜ͱ • "84ͱͷੑ͕ߴ͘ɺؔ࿈αʔϏεଟ͍
• ҟͳΔϦʔδϣϯͷσϓϩΠɺڥͱͷဃݕग़ • 5FSSBGPSN • ಉ͡ߏจͰҧ͏*BB4ʹσϓϩΠͰ͖Δ • 1SPWJEFS͕Γସ͑ΒΕΔނͷϝϦοτ • ߏจόʔδϣϯཧ͕ϓϩάϥϛϯάݴޠʹ͍ۙ • ϓϩάϥϜܦݧͷ͋ΔํೃછΈ͍͔͢
39 ऴΘΓ օ͞Μͷૉఢͳ *B$ϥΠϑΛԠԉͯ͠·͢ʂ
None