Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Terraformerのおはなし
Search
int
October 02, 2019
Programming
3.8k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Terraformerのおはなし
int
October 02, 2019
More Decks by int
See All by int
CIのモニタリングにstackdirver使ってみてる話
int_tt
0
160
Other Decks in Programming
See All in Programming
手動確認はもう限界 〜XCUITestでCustom URL Schemeの遷移を起動種別ごとに自動テストする〜 / Testing Custom URL Schemes with XCUITest
otouto
0
390
JRuby: Past, Present, and Future
headius
0
220
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
350
Rでドレミ/Do-Re-Mi_with_R
florets1
0
120
Agents on Rails - Rails at Scale 2026
irinanazarova
0
330
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
330
APNsからLive Activityを開始する話
yumnumm
0
150
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
140
Are APIs Still Relevant in the AI Era?
soyuka
0
410
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
20
21k
SREの越境 / SRE Collaboration
y0hgi
2
300
Simple Storage Service(S3) is not simple
iwatsukayura
0
150
Featured
See All Featured
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
58k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
290
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
490
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
[SF Ruby Conf 2025] Rails X
palkan
3
1.4k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
530
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Balancing Empowerment & Direction
lara
6
1.3k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
440
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
Transcript
Terraformerͷ͓ͳ͠ Terraform meetup tokyo#2 LT @int_tt
࣍ ! Terraformerʹ͍ͭͯ ! ΞʔΩςΫνϟհ ! ػೳՃͷํ ! ௐͯΈͯ !
ࢀߟࢿྉ
terraformer ͬͨ͜ͱ͋Δਓʙ
Terraformerͱ ! https://github.com/GoogleCloudPlatform/terraformer ! WazeࣾͷSREνʔϜʹΑͬͯ࡞ ! ରԠ͍ͯ͠ΔSaaS,IaaSͷطଘใΛݩʹtfstateͱtfϑΝΠϧΛ࡞ ! ϦιʔεΛࢦఆ͢ΔͱҰׅͰશ෦(!) ɹɹɹɹɹɹɹɹɹ
͖࣋ͬͯͯ͘ΕΔ ! aws,gcp,datadogͨ͘͞Μͷproviderɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹ ʹରԠ
͍͍ܰํ terraformer import google --resources=logging --projects=playground 2019/10/02 17:41:09 google importing
project playground-226302 region global 2019/10/02 17:41:10 google importing... logging 2019/10/02 17:41:10 [TRACE] GRPCProvider: GetSchema 2019/10/02 17:41:10 [TRACE] GRPCProvider: Configure 2019/10/02 17:41:10 [TRACE] GRPCProvider: GetSchema 2019/10/02 17:41:11 [TRACE] GRPCProvider: GetSchema 2019/10/02 17:41:11 [TRACE] GRPCProvider: Configure 2019/10/02 17:41:11 Refreshing state... google_logging_metric.hog 2019/10/02 17:41:11 [TRACE] GRPCProvider: GetSchema 2019/10/02 17:41:11 Refreshing state... google_logging_metric.fuga 2019/10/02 17:41:11 [TRACE] GRPCProvider: GetSchema 2019/10/02 17:41:11 [TRACE] GRPCProvider: ReadResource 2019/10/02 17:41:11 [TRACE] GRPCProvider: ReadResource 2019/10/02 17:41:12 google Connecting.... 2019/10/02 17:41:12 google save logging 2019/10/02 17:41:12 [DEBUG] New state was assigned lineage "7bfb14fa-5e9e-4fb8-456d-1feab006acdd" 2019/10/02 17:41:12 google save tfstate for logging . ├── generated │ └── google │ └── playground-226302 │ └── logging │ └── global │ ├── logging_metric.tf │ ├── outputs.tf │ ├── provider.tf │ └── terraform.tfstate └── provider.tf
resource "google_logging_metric" "fuga" { bucket_options { exponential_buckets { growth_factor =
"2" num_finite_buckets = "64" scale = "0.01" } } description = "fuga" filter = "resource.type=\"k8s_cluster\"\nresource.labels.location=\"us-central1-a\"\nresource.labels.cluster_name=\"standard-cluster-1\"\n" label_extractors = {} metric_descriptor { metric_kind = "DELTA" value_type = "DISTRIBUTION" } name = "fuga" project = "playground-226302" value_extractor = "EXTRACT(protoPayload.@type)" } resource "google_logging_metric" "hoge" { description = "hoge" filter = "resource.type=\"k8s_cluster\"\nresource.labels.location=\"us-central1-a\"\nresource.labels.cluster_name=\"standard-cluster-1\"\n" label_extractors = {} metric_descriptor { metric_kind = "DELTA" unit = "1" value_type = "INT64" } name = "hog" project = "playground-226302" }
ΞʔΩςΫνϟհ terraformer import google --resources=logging --projects=playground Terraformer લॲཧ providerͱͷ௨৴ औಘ݁Ռͷparse
ΞʔΩςΫνϟհ terraformer import google --resources=logging --projects=playground Terraformer લॲཧ providerͱͷ௨৴ औಘ݁Ռͷparse
•ίϚϯυͷparse • provider͝ͱͷॳظઃఆ • ରԠͯ͠ΔϦιʔε͔ʙ • ରԠ͍ͯ͠ΕͦͷϦιʔεͷҰཡΛऔಘ͠ɺIDͱϦιʔ ε໊Ληοτ͢Δ • providerͱͷ௨৴४උ ىಈ͔Β https://github.com/GoogleCloudPlatform/terraformer/blob/0.8.1/cmd/import.go ͷfunc ImportͷલลΓ
ΞʔΩςΫνϟհ terraformer import google --resources=logging --projects=playground Terraformer લॲཧ providerͱͷ௨৴ औಘ݁Ռͷparse
provider-google •ࢦఆͨ͠ϦιʔεͷRefresh(Read) Λୟ͍ͯ݁ՌΛड͚औΔ • rpc͔grpcͰ௨৴ https://github.com/GoogleCloudPlatform/terraformer/blob/0.8.1/cmd/import.go ͷfunc Importͷޙ ֤छproviderͷresourcesลΓ
ΞʔΩςΫνϟհ terraformer import google --resources=logging --projects=playground Terraformer લॲཧ providerͱͷ௨৴ औಘ݁Ռͷparse
•↑Ͱಘͨ݁ՌΛࣗྗͰparseͯ͠ tf,tfstateϑΝΠϧΛग़ྗ͢Δ https://github.com/GoogleCloudPlatform/terraformer/blob/0.8.1/cmd/import.go ͷfunc ImportFromPlanลΓ
ػೳՃͷํ ! ༰GCPͷlogging_metrics resouceͷରԠ ! PR(https://github.com/GoogleCloudPlatform/terraformer/pull/173)Λૹͬͨͱ ͖ʹͬͨ͜ͱ ! ଞαϯϓϧΛݩʹϦιʔεҰཡͷऔಘΛ͍ͯ͠߹Θͤ෦ΛΈཱͯ Δ(providers/gcp/logging.go)
! ࣮ߦ࣌ҾͱϝιουͷରԠ͚(providers/gcp/gcp_provider.go) ! READMEΛॻ͘(README.md) ! ΞʔΩςΫνϟͰݴ͏લॲཧͷ෦͚ͩʂʂʂ
func (g *LoggingGenerator) loadLoggingMetrics(ctx context.Context, client *logadmin.Client) error { metricIterator:=
client.Metrics(ctx) for{ metric, err := metricIterator.Next() if err == iterator.Done { break } if err != nil { return err } g.Resources = append(g.Resources, terraform_utils.NewResource( metric.ID, metric.ID, "google_logging_metric", "google", map[string]string{ "name": metric.ID, "project": g.GetArgs()["project"].(string), }, loggingAllowEmptyValues, loggingAdditionalFields, )) } return nil } ͜Εͱ
͜Εͱ͜Ε͚ͩ
ௐͯΈͯ ! providerΛ͏·͘͏͜ͱͰॲཧΛ࠷খݶʹ͑ͭͭɺࠓޙͷରԠ؆୯ʹ ߦ͑ΔΑ͏ʹͳ͍ͬͯΔ ! terraformerੌ͍͚Ͳterraformͷpluginػߏੌ͍ ! ֤छpluginSaasͷresourcesͷCRUD෦ΛநԽͯ͘͠Ε͍ͯΔๅ ശ !
terraformຊମʹґଘͤͣΤίγεςϜΛ૿͍ͯ͘͜͠ͱͰ͖ͦ͏
ࢀߟࢿྉ ! ιʔείʔυ:https://github.com/GoogleCloudPlatform/terraformer ! 3rd Party tool Λ͖͔͚ͬʹ Terraform ͷιʔείʔυΛগ͠ᅂΜͩ
https://chroju.github.io/blog/2019/05/14/read_terraform_source_code/ ! Terraform Provider࣮ ೖ(1): Custom Providerͷجૅ ! http://febc-yamamoto.hatenablog.jp/entry/terraform-custom-provider-01