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
500
スクラム勉強会
yusukeyasuo
0
180
Rails×Serverless
yusukeyasuo
0
96
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
65
4.4k
Embracing the Ebb and Flow
colly
84
4.5k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
130
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
GraphQLとの向き合い方2022年版
quramy
43
13k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
GitHub's CSS Performance
jonrohan
1030
460k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
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