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
730
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
760
コードを書く前に既に勝負は決まっている
yusukeyasuo
3
1k
Rails6新機能 複数DB対応について
yusukeyasuo
0
510
スクラム勉強会
yusukeyasuo
0
190
Rails×Serverless
yusukeyasuo
0
97
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Producing Creativity
orderedlist
PRO
343
39k
Adopting Sorbet at Scale
ufuk
74
9.1k
Designing Experiences People Love
moore
139
23k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
VelocityConf: Rendering Performance Case Studies
addyosmani
327
24k
It's Worth the Effort
3n
183
28k
RailsConf 2023
tenderlove
29
960
Making the Leap to Tech Lead
cromwellryan
133
9k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.8k
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