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 at Wantedly
Search
Daisuke Fujita
August 05, 2015
Technology
15
10k
Terraform at Wantedly
HashiCorp Tools Meetup #hashi_wantedly での発表資料です。
Daisuke Fujita
August 05, 2015
Tweet
Share
More Decks by Daisuke Fujita
See All by Daisuke Fujita
SREcon19 Asia/Pacific Recap
dtan4
0
150
Our Practices of Delegating Ownership in Microservices World
dtan4
4
8.8k
Kubernetes Cluster Upgrade / Mercari Meetup for Microservices Platform
dtan4
3
4.5k
KubeCon EU 2018 Recap: Multi-Tenancy in Kubernetes: Best Practices Today, and Future Directions / Kubernetes Meetup Tokyo 11 #k8sjp
dtan4
1
1.8k
Wantedly から Chef を一掃した話 / #chibadan
dtan4
24
11k
さようなら Chef こんにちは Dockerfile / Web Tech Tokyo #1
dtan4
6
7k
Docker をフル活用したインフラの紹介と成長し続けるためのインフラ戦略 / #abejameetup
dtan4
19
3.9k
Docker Compose PaaS の作り方、そして社内に導入した話 / #yapc8oji
dtan4
1
8.2k
Writing Kubenetes tools in Go
dtan4
1
3.5k
Other Decks in Technology
See All in Technology
Mini Tokyo 3D × PLATEAU - 公共交通デジタルツインにリアルな風景を
nagix
1
230
AWS⼊社という選択肢、⾒えていますか
iwamot
2
1.1k
製造現場のデジタル化における課題とPLC Data to Cloudによる新しいアプローチ
hamadakoji
0
190
DatabricksにおけるLLMOpsのベストプラクティス
taka_aki
4
1.6k
AI長期記憶システム構築のための LLMマルチエージェントの取り組み / Awarefy-LLM-Multi-Agent
iktakahiro
2
340
エンジニアが一生困らない ドキュメント作成の基本
naohiro_nakata
2
140
隣接領域をBeyondするFinatextのエンジニア組織設計 / beyond-engineering-areas
stajima
1
200
3次元点群データ「VIRTUAL SHIZUOKA』のオープンデータ化による恩恵と協働の未来/FOSS4G Japan 2024
kazz24s
0
120
徹底比較!HA Kubernetes ClusterにおけるControl Plane LoadBalancerの選択肢
logica0419
2
140
What to do after `laravel new`
mattstauffer
0
140
「 SharePoint 難しい」ってよく聞くけど、そんなに言うなら8歳の息子に試してもらった
taichinakamura
2
790
20241108_CS_LLMMT
shigashiyama
0
240
Featured
See All Featured
A Tale of Four Properties
chriscoyier
156
23k
Bash Introduction
62gerente
608
210k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
RailsConf 2023
tenderlove
29
890
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
The Cost Of JavaScript in 2023
addyosmani
45
6.7k
Building Applications with DynamoDB
mza
90
6.1k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
92
16k
StorybookのUI Testing Handbookを読んだ
zakiyama
26
5.2k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Why Our Code Smells
bkeepers
PRO
334
57k
Transcript
TERRAFORM at WANTEDLY 2015-08-05 HashiCorp Tools Meetup @dtan4
Daisuke Fujita @dtan4 Πϯλʔϯ @ΠϯϑϥνʔϜ
None
HashiCorp in Wantedly Terraform Vagrant Packer
ࠓ͢͜ͱ Wantedly Ͱͷ Terraform ӡ༻ࣄྫ
Terraform flow @ Wantedly since May 2015
Terraform Ͱཧ͍ͯ͠Δ 27 resource types aws_customer_gateway aws_db_instance aws_db_security_group aws_db_subnet_group aws_elasticache_cluster
aws_elasticache_subnet_group aws_elb aws_iam_group aws_iam_group_membership aws_iam_group_policy aws_iam_role aws_iam_role_policy aws_iam_user aws_iam_user_policy aws_instance aws_internet_gateway aws_network_acl aws_route_table aws_route_table_association aws_s3_bucket aws_security_group aws_subnet aws_vpc aws_vpn_connection aws_vpn_connection_route aws_vpn_gateway dnsimple_record
Terraform Ͱཧ͍ͯ͠Δ AWS 199 DNSimple 155 354 resources
Terraform ڥ GitHub wercker S3 remote backend Vagrant CoreOS Docker
quay.io/wantedly/terraform 3FNPUF -PDBM
Terraform flow Terraform ίʔυΛॻ͍ͯ Pull Request Λग़͢
Terraform flow Terraform ίʔυΛॻ͍ͯ Pull Request Λग़͢
Terraform flow CI Ͱςετ (terraform plan) ͕Δ
Terraform flow CI Ͱςετ (terraform plan) ͕Δ
Terraform flow ΠϯϑϥνʔϜ͕ϨϏϡʔͯ͠ Merge
Terraform flow CI Ͱ࣮ڥͷద༻ (terraform apply) ͕ߦΘΕΔ
Terraform flow CI Ͱ࣮ڥͷద༻ (terraform apply) ͕ߦΘΕΔ
e.g. DNS ϨίʔυՃ
e.g. IAM ϢʔβՃ
e.g. GitHub ্Ͱ֬ೝͰ͖ͯศར
Terraform ಋೖͷաఔ
ಋೖͨ͠ܦҢ • Management Console ϙνϙνۀ͔Βͷ٫ • ΠϯϑϥνʔϜͷ࡞ۀूத͔Βͷ٫ • ߏங࡞ۀͷཤྺΛ͍ͨ͠ •
ϦιʔεҰཡΛ ͩΕͰ؆୯ʹݟΒΕΔΑ͏ʹ͍ͨ͠ • ϦιʔεෳΛָʹ͍ͨ͠
Ұ͔ΒΠϯϑϥߏஙϦϓϨʔεͰͳ͘ɺ ͍·ಈ͍͍ͯΔΠϯϑϥϦιʔε ΛίʔυԽ͍ͨ͠
ݱߦڥͷ Terraform ಋೖ https://github.com/hashicorp/terraform/issues/581
ݱߦڥͷ Terraform ಋೖ https://github.com/hashicorp/terraform/issues/581 طଘϦιʔεͷ Terraform ίʔυԽ ࣮͞Ε͍ͯͳ͍
ݱߦڥͷ Terraform ಋೖ ex: hoge ͱ͍͏ S3 bucket ͕͋ͬͨͱ͖ resource
"aws_s3_bucket" "hoge" { bucket = "hoge" acl = "private" } { "version": 1, "serial": 1, "modules": { "path": [ "root" ], "outputs": { }, "resources": { "aws_s3_bucket.hoge": { "type": "aws_s3_bucket", "primary": { "id": "hoge", "attributes": { "acl": "private", "bucket": "hoge", "id": "hoge" } } } } } } TUG UFSSBGPSNUGTUBUF
ݱߦڥͷ Terraform ಋೖ ex: hoge ͱ͍͏ S3 bucket ͕͋ͬͨͱ͖ resource
"aws_s3_bucket" "hoge" { bucket = "hoge" acl = "private" } { "version": 1, "serial": 1, "modules": { "path": [ "root" ], "outputs": { }, "resources": { "aws_s3_bucket.hoge": { "type": "aws_s3_bucket", "primary": { "id": "hoge", "attributes": { "acl": "private", "bucket": "hoge", "id": "hoge" } } } } } } TUG UFSSBGPSNUGTUBUF tfstate (JSON) ਓྗͰॻ͘ͷݫ͍͠
Export existing AWS resources to Terraform style (tf, tfstate) dtan4/terraforming
Terraforming • طଘͷ AWS / DNSimple Ϧιʔε͔Β Terraform ͷίʔυ (tf,
tfstate) Λੜ͢Δ ίϚϯυϥΠϯπʔϧ • 24छྨͷ AWS ϦιʔεʹରԠ • Wantedly ͷ Terraform ίʔυͷେΛੜ • Issue & Pull Request ͓·ͪͯ͠·͢ʂ dtan4/terraforming $ gem install terraforming # or $ docker pull quay.io/dtan4/terraforming
Terraforming • S3 buckets ͷ tf Λੜ • S3 buckets
ͷ tfstate Λੜ • S3 buckets ͷ tfstate Λੜ͠ɺ طଘͷ terraform.tfstate ͱϚʔδ $ terraforming s3 $ terraforming s3 --tfstate \ --merge=/path/to/terraform.tfstate $ terraforming s3 --tfstate dtan4/terraforming
http://qiita.com/dtan4/items/345c56281ab0e87d6646
ૺ۰ͨ͠
terraform plan ͕৴༻ग़དྷͳ͍ • HCL ͷγϯλοΫενΣοΫͱ Terraform ύϥϝʔλͷνΣοΫͷΈɺ API ͷ
dry-run ͠ͳ͍ • terraform plan ͕௨ͬͯɺύϥϝʔλ͕ AWS తʹෆਖ਼Ͱ terraform apply ʹࣦഊ͢Δ • CI Ͱʮςετʯ͍ͯ͠Δҙຯ͕…
terraform plan ͕৴༻ग़དྷͳ͍ • AWS ͷυΩϡϝϯτಡ·ͳ͍ͱ͍͚ͳ͍ • terraform apply ࣦഊͯ͠ϦΧόϦͰ͖Δ
ΈΛ࡞Δ • खݩͰ apply Ͱ͖Δڥ
ELB ԼͷΠϯελϯε͕ ҙਤͤͣஔ͖ΘΔ • Terraform ͷ ELB resource Δ͢ΠϯελϯεΛ໌ࣔతʹॻ͘ඞཁ͋Γ
• Wantedly ͰࣗલπʔϧͰ Πϯελϯεͷ૿ݮɺELB ͷΔ͠Λߦ͏ • Terraform ίʔυͱ࣮ࡍͷڥʹࠩҟ͕ग़Δ
ELB ԼͷΠϯελϯε͕ ҙਤͤͣஔ͖ΘΔ • සൟʹΠϯελϯε͕ஔ͖ΘΔ ELB Terraform Ͱཧ͠ͳ͍͜ͱʹͨ͠ •
֎෦Ͱಈతͳมߋ͕͋Γ͏ΔϦιʔε ͋͑ͯཧ͠ͳ͍
IAM ϢʔβআͰࣦഊ • IAM ϢʔβࣗମΛফ͢લʹΫϨσϯγϟϧ ϩάΠϯϓϩϑΝΠϧΛফ͢ඞཁ͕͋Δ • Terraform ͦΜͳͷ͓ߏ͍ͳ͠ʹ delete-user
͠Α͏ͱ͢Δ • खಈͰґଘϦιʔεΛফ্ͨ͠Ͱ apply http://docs.aws.amazon.com/ja_jp/IAM/latest/UserGuide/Using_DeletingUserFromAccount.html
·ͱΊ
·ͱΊ • Wantedly ͷΠϯϑϥ Terraform Ͱཧ͞Ε͍ͯ·͢ʂ • ݱߦΠϯϑϥΛ Terraform Ͱཧ͢ΔͨΊʹ
Terraforming ͱ͍͏πʔϧΛ։ൃ͠·ͨ͠ • ͯ͢Λ Terraform ʹ͖ͤͬΓʹ͠ͳ͍