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ではじめるInfrastructure as Code
Search
Yusuke Yasuo
October 18, 2018
1
710
TerraformではじめるInfrastructure as Code
「JAWS-UG 初心者支部#14」のLT資料です。
Yusuke Yasuo
October 18, 2018
Tweet
Share
More Decks by Yusuke Yasuo
See All by Yusuke Yasuo
Rails開発で技術的負債を増やさないためにやっていること
yusukeyasuo
0
750
コードを書く前に既に勝負は決まっている
yusukeyasuo
3
1k
Rails6新機能 複数DB対応について
yusukeyasuo
0
490
スクラム勉強会
yusukeyasuo
0
180
Rails×Serverless
yusukeyasuo
0
96
Featured
See All Featured
Music & Morning Musume
bryan
46
6.1k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
Unsuck your backbone
ammeep
668
57k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.6k
Measuring & Analyzing Core Web Vitals
bluesmoon
0
9
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.8k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
A better future with KSS
kneath
237
17k
Making the Leap to Tech Lead
cromwellryan
131
8.9k
Speed Design
sergeychernyshev
23
550
No one is an island. Learnings from fostering a developers community.
thoeni
19
2.9k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Transcript
TERRAFORMͰ͡ΊΔ INFRASTRACTURE AS CODE yusukeyasuo@redish
ର • ඇΠϯϑϥΤϯδχΞͰɺΠϯϑϥͷߏஙɾӡ༻͠ͳ͖Ό͍ ͚ͳ͘ͳͬͨΤϯδχΞ • ·ͩInfrastructure as CodeΛ͍ͯ͠ͳ͍ΠϯϑϥΤϯδχΞ • தʙ্ڃऀ͚Ͱͳ͍Ͱ͢m(__)m
AGENDA • ࣗݾհ • Infrastructure as Codeͱ • Terraformͱ •
࣮ྫ • ·ͱΊ
ࣗݾհ • Yusuke Yasuo • ϦʔυΤϯδχΞ@redishגࣜձࣾ • NTT→ίϩϓϥ→ελʔτΞοϓΛࣾ • ελʔτΞοϓͰΤϯδχΞ1ʙ2ਓͷ࣌
ظ͕͋ΓɺAWSΛ৮ΔΑ͏ʹͳͬͨ
INFRASTRUCTURE AS CODEͱ • ίʔυʹΑΔΠϯϑϥߏཧ
ͳͥίʔυཧ͕ඞཁ͔ʁ • खಈͰཧ͢Δͱେม͔ͩΒ
͕ܦݧͨ͠खಈཧͷฐ • υΩϡϝϯτɺखॱॻ͕ͳ͍ͷͰͲ͏ͬͯߏங͔ͨ͠୲ ऀʹฉ͔ͳ͍ͱ͔Βͳ͍ • ୲ऀʹฉ͍ͯߏங࣌ͷهԱ͕ͳ͔ͯ͘Βͳ͍ • ো͕ൃੜͨ͠ࡍʹ෮چͰ͖ͳ͍ • పͰθϩ͔Βߏங͢Δ
• ୀ৬ޙো͕ൃੜ͢Δͱݺͼग़͞ΕΔ
ίʔυԽ͓͚ͯ͠ • Πϯϑϥͷઃఆ͕୭Ͱ͔ΔʢϒϥοΫϘοΫεԽ͠ ͳ͍ʣ • ো͕ൃੜͯ͠ίϚϯυҰͭͰ͙͢ʹ෮چ͕Մೳ • ࡞ۀϛεى͜Βͳ͍ • ΠϯϑϥΤϯδχΞ͕͍ͳͯ͘ཧͰ͖Δ
ओͳπʔϧ
TERRAFORMͱ • ΠϯϑϥετϥΫνϟఆٛπʔϧ • VagrantͳͲ։ൃ͍ͯ͠ΔHashiCorp͕ࣾ։ൃݩ • ΠϯϑϥͷߏΛએݴతʹఆٛͰ͖Δ ※खଓ͖తʹॻ͔ͳͯ͘ྑ͍
Πϯετʔϧ • ϏϧυࡁΈόΠφϦΛμϯϩʔυͯ͠ύεΛ௨͚ͩ͢
ࣄલ४උ • IAMϢʔβʔͷ࡞ • AWS CLIΛར༻͢ΔͨΊͷIAMϢʔβʔΛ࡞͠ɺΞΫηεΩʔΛऔಘ͢Δ • AWS CLIͷηοτΞοϓ •
$ aws configure ͰೝূใΛηοτ͢Δ ※ ~/.aws/credentials ʹೝূใ͕อଘ͞Ε͍ͯΕOK • terraformͷॳظԽ • $ terraform init
RDSΛ࡞͢Δྫ
ఆٛϑΝΠϧͷ࡞ provider "aws" { region = "ap-northeast-1" } resource "aws_db_instance"
"default" { allocated_storage = 10 storage_type = "gp2" engine = "mysql" engine_version = "5.7" instance_class = "db.t2.micro" name = "mydb" username = "foo" password = "foobarbaz" parameter_group_name = "default.mysql5.7" } rds.tf
༰ͷνΣοΫ • $ terraform plan
RDSͷ࡞ • $ terraform apply
࡞ͨ͠ΦϒδΣΫτͷ֬ೝ • $ terraform show
ҙ͢Δ͜ͱ • TerraformͰ࡞ͨ͠ΦϒδΣΫτΛखಈͰมߋ͠ͳ͍ • ෳਓͰ࡞ۀ͢Δ߹tfstateͷཧʹؾΛ͚ͭΑ͏
·ͱΊ • ϓϩμΫγϣϯ༻ͷΠϯϑϥඞͣίʔυԽ͠·͠ΐ͏ • ίʔυԽ͠ͳ͍ͷϦϦʔε͠ͳ͍ • redishͰҰॹʹInfrastructure as Code͠·͠ΐ͏w