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
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.5k
デプロイ直後のレイテンシスパイクを調べたら、 Railsの仕様にたどり着いた
nhsykym
0
110
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
300
[DroidKaigi 2026] Bring your own phones to Gradle Managed Devices
f2lk
0
110
【高い買い物LT会】初任給で話題の国産フィジカルAIを買った話
akagami
PRO
0
130
RSSとCodexを使ってX投稿自動化してみた
ochtum
0
110
Seeing Through Serverless: Observability for AWS Lambda with ADOT and CloudWatch Application Signals
seike460
PRO
1
130
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
4
1.1k
新人はどこまで自力でやり、どこからAIに頼るべきか/エンジニア育成に向き合う_先輩たちの悩みと知見共有会
toppan_digital_dev
1
590
自分的「カンファレンスの楽しみ方」
syumai
0
200
フロントエンドUIフレームワークのこれまでとこれから
ssssota
4
2k
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
1.6k
Featured
See All Featured
Building the Perfect Custom Keyboard
takai
2
870
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
490
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.3k
Site-Speed That Sticks
csswizardry
13
1.5k
The Cult of Friendly URLs
andyhume
79
7k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
730
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Balancing Empowerment & Direction
lara
6
1.3k
Into the Great Unknown - MozCon
thekraken
41
2.7k
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