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
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
Application Development WG Intro at AppDeveloperCon
salaboy
0
180
Terraform CI/CD パイプラインにおける AWS CodeCommit の代替手段
hiyanger
1
240
B2B SaaSから見た最近のC#/.NETの進化
sansantech
PRO
0
660
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
【若手エンジニア応援LT会】ソフトウェアを学んできた私がインフラエンジニアを目指した理由
kazushi_ohata
0
140
B2B SaaS × AI機能開発 〜テナント分離のパターン解説〜 / B2B SaaS x AI function development - Explanation of tenant separation pattern
oztick139
2
220
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
460
いざ、BSC討伐の旅
nikinusu
2
770
個人でもIAM Identity Centerを使おう!(アクセス管理編)
ryder472
3
170
AWS Media Services 最新サービスアップデート 2024
eijikominami
0
190
Platform Engineering for Software Developers and Architects
syntasso
1
510
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
2
570
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
Music & Morning Musume
bryan
46
6.2k
Thoughts on Productivity
jonyablonski
67
4.3k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
4 Signs Your Business is Dying
shpigford
180
21k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Embracing the Ebb and Flow
colly
84
4.5k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Faster Mobile Websites
deanohume
305
30k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
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