Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
tfnotify - Show Terraform execution plan beauti...
Search
BABAROT
September 11, 2018
Technology
5
13k
tfnotify - Show Terraform execution plan beautifully on GitHub
https://hashicorp.connpass.com/event/98386/
BABAROT
September 11, 2018
Tweet
Share
More Decks by BABAROT
See All by BABAROT
SLOをゼロからつくる
b4b4r07
15
5.9k
Cloud Functions in Go at Mercari
b4b4r07
9
5.7k
Insert an Example of Software Engineer Here
b4b4r07
4
1.8k
Kubernetes manifests management and operation in Mercari
b4b4r07
27
6.9k
Testing with YAML
b4b4r07
5
5.1k
Micoservices Platform in Mercari
b4b4r07
3
150
Terraform Ops for Microservices
b4b4r07
16
15k
シェルスクリプトを書く技術
b4b4r07
3
1.1k
Other Decks in Technology
See All in Technology
クルマのサブスクを Next.jsで内製化した経験とその1年後
kintotechdev
2
370
総会員数1,500万人のレストランWeb予約サービスにおけるRustの活用
kymmt90
3
2.6k
電話を切らさない技術 電話自動応答サービスを支える フロントエンド
barometrica
2
1.8k
ARRが3年で10倍になったプロダクト開発とAI活用の軌跡
akiroom
0
170
次のコンテナセキュリティの時代 - User Namespace With a Pod / CloudNative Days Winter 2024
pfn
PRO
4
380
日本全国・都市3D化プロジェクト「PLATEAU」とデータ変換OSS「PLATEAU GIS Converter」の公開
nokonoko1203
2
250
バクラクのデータ基盤をBigQueryからSnowflakeへ移管した理由 / The reason for migrating Bakuraku data infrastructure from BigQuery to Snowflake
civitaspo
0
110
Amazon ECSとCloud Runの相互理解で広げるクラウドネイティブの景色 / Mutually understanding Amazon ECS and Cloud Run
iselegant
18
2.1k
モバイルアプリ開発未経験者が プロダクト開発に携わるまでに取り組んだこと/nikkei-tech-talk-27-3
nikkei_engineer_recruiting
0
110
Android 15 でウィジェットピッカーのプレビュー画像をGlanceで魅せたい/nikkei-tech-talk-27-1
nikkei_engineer_recruiting
0
120
セキュリティ運用って包括的にできていますか?SaaSを使って次のステップへ / Comprehensive Cyber Security Operations for Cloud Services Using SaaS
sakaitakeshi
0
260
Amazon Forecast亡き今、我々がマネージドサービスに頼らず時系列予測を実行する方法
sadynitro
0
210
Featured
See All Featured
Speed Design
sergeychernyshev
25
640
Designing for humans not robots
tammielis
250
25k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
How to Ace a Technical Interview
jacobian
276
23k
Practical Orchestrator
shlominoach
186
10k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Why Our Code Smells
bkeepers
PRO
334
57k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
0
47
How STYLIGHT went responsive
nonsquared
95
5.2k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Faster Mobile Websites
deanohume
305
30k
Transcript
tfnotify @b4b4r07 (Sep 11, 2018) / HashiCorp Meetup #3 DevOps
Λࢧ͑Δࠓͷ HashiCorp πʔϧ܈ʹ͍ͭͯ Show Terraform execution plan beautifully on GitHub
BABAROT / @b4b4r07 Mercari, Inc. SRE, Microservices Platform Blog /
tellme.tokyo
1. mercari/tfnotify 2. Why tfnotify? 3. Implementations Agenda
mercari/tfnotify
• Go CLI πʔϧ • Terraform ͷ࣮ߦ݁ՌΛύʔε͠ɺ దͳϑΥʔϚοτʹ͋ͯΊͯɺ ҙͷ௨ઌ
(GitHub ͷίϝϯτ) ௨͢Δ tfnotify ͱ
tfnotify Workflow DSFBUFE UFSSBGPSNQMBOcUGOPUJGZQMBO 1045DPN N FOU PVUQVU
tfnotify Workflow N FSHFE UFSSBGPSNBQQMZcUGOPUJGZBQQMZ 1045DPN N FOU PVUQVU
Example • fmt • plan • apply
Example {{.Title}} {{.Message}} {{.Result}} {{.Body}} ࣮ߦग़ྗͯ͢ ࣮ߦ݁ՌͷαϚϦ --messageͰͤΔ ҙͷλΠτϧ
Why tfnotify?
ͳͥඞཁͱͳͬͨͷ͔ • ϝϧΧϦͰ Microservices ྖҬͰ Terraform Λར༻͍ͯ͠Δ • Ownership ͷ؍͔ΒΠϯϑϥཧʹ͓͍ͯϨϏϡʔɾϚʔδ
֤ Micorservices νʔϜʹΑͬͯ͞ΕΔ͖ • ͱ͍ͬͯɺPlatform νʔϜʹϨϏϡʔ͞Ε͍ͨέʔε͋Δ
ͳͥඞཁͱͳͬͨͷ͔ • Platform νʔϜͱͯ͠ɺ֤ Microservices νʔϜͱͯ͠ɺ Infrastructure as Code ͷॏཁੑΛཧղ͠
Terraform ͰίʔυԽ͠ɺ ͦͷ࣮ߦܭըΛຖճݟΔ͜ͱΛश׳͚͍ͮͨ • ຖଟ͘ͷ P-R ͕͋ΔதɺCircle CI ʹݟʹ͍͘खؒΛল͖͍ͨ →ϨϏϡʔͷྲྀΕͰ GitHub ্ͰΫΠοΫʹ֬ೝ͍ͨ͠
ϝϧΧϦͰͷ HashiCorp πʔϧ
ϝϧΧϦͰͷ HashiCorp πʔϧ • ϝϧΧϦʹ 70 Ҏ্ͷ Microservices ͕͋Δ (ࠓݱࡏɽ૿͑ଓ͚͍ͯΔ)
• ͯ͢ͷ Microservices ͱͦͷ Platform ͷ Πϯϑϥߏஙʹ Terraform Λར༻͍ͯ͠Δ • Developers ʹ Infrastructure as Code Λ ࣮ફͯ͠Β͏
ϝϧΧϦͰͷ Terraform ར༻ࣄྫ
ϝϧΧϦͰͷ Terraform ར༻ࣄྫ
ϝϧΧϦͰͷ Terraform ར༻ࣄྫ
ϝϧΧϦͰͷ Terraform ར༻ࣄྫ
ϝϧΧϦͰͷ Terraform ར༻ࣄྫ • Insights • 110+ Contributors • 8
~ 10 Pull Requests / week (5 days) • 140+ state files (70+ Microservices * 2 Env) • ͻͱͭͷதԝϦϙδτϦͰͯ͢ͷ Terraform ίʔυΛཧ͍ͯ͠Δ • CI pipeline ͷߏங͕ҰͰࡁΉ • Platform νʔϜ͕ϨϏϡʔʹೖΓ͍͢
ϦϙδτϦߏ • ֤ Microservice ͝ͱʹ σΟϨΫτϦΛ͚Δ • Service ͝ͱʹ tfstate
Λ͚Δ • ӨڹΛଞٴͤ͞ͳ͍ • Resource ͝ͱʹ file Λ͚Δ • ϦιʔεఆٛॴΛ໌֬Խ • CODEOWNERS Ͱݖݶҕৡ
ϦϙδτϦߏ • ֤ Microservice ͝ͱʹ σΟϨΫτϦΛ͚Δ • Service ͝ͱʹ tfstate
Λ͚Δ • ӨڹΛଞٴͤ͞ͳ͍ • Resource ͝ͱʹ file Λ͚Δ • ϦιʔεఆٛॴΛ໌֬Խ • CODEOWNERS Ͱݖݶҕৡ தԝूݖ ཱࣗࢄ
ݖݶҕৡ IUUQTCMPHHJUIVCDPNJOUSPEVDJOHDPEFPXOFST • GitHub ͷػೳ • CODEOWNERS ʹهࡌ͞Ε ͨਓ͔Β Approve
͞ΕΔ ·ͰϚʔδͰ͖ͳ͍Α͏ʹ Ͱ͖Δ • ͜ΕʹΑΓݖݶҕৡΛ࣮ݱ • (উखʹมߋͰ͖ͳ͍)
ݖݶҕৡ IUUQTIFMQHJUIVCDPNBSUJDMFTBCPVUDPEFPXOFST
Ϟδϡʔϧ • microservices-starter-kit (Terraform Ϟδϡʔϧ) • Template Provider Λ͍σΟϨΫτϦ࡞ɺϑΝΠϧు͖ग़͠ •
Microservices ͷ্ཱͪ͛ʹඞཁͳϦιʔεΛ Bootstrap ͢Δ • GCP Project, Service account ͳͲ • PagerDuty, DataDog, Kubernetes (Namespace, Secret) ͳͲ • GitHub Teams (CODEOWNERS ͷݖݶҕৡʹ͏) IUUQTTQFBLFSEFDLDPNCCSUFSSBGPSNPQTGPSNJDSPTFSWJDFT
Implementations
࣮ • io.TeeReader Λ͍ͬͯΔ • GitHub ʹ POST ͢Δ͚ͩͰ ͳ͘
CI ͷ Console ʹग़ྗ • Terraform ͷ࣮ߦ݁Ռࣗલͷ ύʔαͰߏԽ͢Δ (regexp) • POST ͢Δϝοηʔδ Go ͷ ςϯϓϨʔτͰॻ͘͜ͱ͕Ͱ͖Δ • ઃఆ YAML Ͱ࣋ͭ
࣮ • ॏෳͨ͠༰͕͋Δ߹ɺ ݹ͍ͷ͕আ͞ΕΔ • ࣮ߦ݁Ռ͍ͷͰ Details λά ͰғͬͯંΓͨͨΈɺҰṮʹඞཁ ͳใ͚͕ͩݟ͘͢දࣔ͞ΕΔ
{{.Title}}, {{.Message}} ͷॏෳΛݟΔ
Conclusion
·ͱΊ • ϝϧΧϦͰ Microservices ྖҬͰ Terraform Λར༻͍ͯ͠Δ • ूݖͱࢄͷόϥϯεͰ Terraform
ϦϙδτϦΛӡ༻͍ͯ͠Δ • ͨ͘͞Μͷ P-R ΛޮΑ͘ϨϏϡʔ͢ΔͨΊ tfnotify Λॻ͍ͨ • Terraform ͷ࣮ߦ݁ՌΛखܰʹ֬ೝ͍ͨ͠ • Infrastructure as Code ͷจԽΛ͔ࠜͤΔ • ຖճ plan, apply ݁ՌΛݟΔश׳Λͭ / ͬͯΒ͏ • ઌߦ࣮͕ͳ͍ͨΊ OSS ʹͨ͠
Thanks