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
フルカイテン株式会社 採用資料
fullkaiten
0
40k
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
570
rootlessコンテナのすゝめ - 研究室サーバーでもできる安全なコンテナ管理
kitsuya0828
3
380
Amazon CloudWatch Network Monitor のススメ
yuki_ink
1
200
Lexical Analysis
shigashiyama
1
150
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
210
信頼性に挑む中で拡張できる・得られる1人のスキルセットとは?
ken5scal
2
530
B2B SaaS × AI機能開発 〜テナント分離のパターン解説〜 / B2B SaaS x AI function development - Explanation of tenant separation pattern
oztick139
2
220
ハイパーパラメータチューニングって何をしているの
toridori_dev
0
140
Lambdaと地方とコミュニティ
miu_crescent
2
370
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
120
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
A better future with KSS
kneath
238
17k
Adopting Sorbet at Scale
ufuk
73
9.1k
Embracing the Ebb and Flow
colly
84
4.5k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Unsuck your backbone
ammeep
668
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 ʹ͖ͤͬΓʹ͠ͳ͍