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
applibotのDevOpsを支える terraform/packer
Search
遊
September 11, 2018
Technology
1
3.4k
applibotのDevOpsを支える terraform/packer
2018/09/11 DevOpsを支える今話題のHashiCorpツール群について
遊
September 11, 2018
Tweet
Share
More Decks by 遊
See All by 遊
ゲームのインフラ6年やっててよく聞かれること
gacharu
1
1.2k
ELKstackとAthenaの素敵な関係
gacharu
0
960
Other Decks in Technology
See All in Technology
30分でわかる「リスクから学ぶKubernetesコンテナセキュリティ」/30min-k8s-container-sec
mochizuki875
3
450
Unsafe.BitCast のすゝめ。
nenonaninu
0
200
KMP with Crashlytics
sansantech
PRO
0
240
When Windows Meets Kubernetes…
pichuang
0
310
Azureの開発で辛いところ
re3turn
0
240
三菱電機で社内コミュニティを立ち上げた話
kurebayashi
1
360
データ基盤におけるIaCの重要性とその運用
mtpooh
4
530
EMConf JP の楽しみ方 / How to enjoy EMConf JP
pauli
2
150
【Oracle Cloud ウェビナー】2025年のセキュリティ脅威を読み解く:リスクに備えるためのレジリエンスとデータ保護
oracle4engineer
PRO
1
100
ABWGのRe:Cap!
hm5ug
1
120
RubyでKubernetesプログラミング
sat
PRO
4
160
技術に触れたり、顔を出そう
maruto
1
160
Featured
See All Featured
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.2k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Facilitating Awesome Meetings
lara
51
6.2k
VelocityConf: Rendering Performance Case Studies
addyosmani
327
24k
A Philosophy of Restraint
colly
203
16k
A Tale of Four Properties
chriscoyier
157
23k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Adopting Sorbet at Scale
ufuk
74
9.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.5k
The Cult of Friendly URLs
andyhume
78
6.1k
KATA
mclloyd
29
14k
Transcript
applibotͷDevOpsΛࢧ͑Δ terraform/packer DevOpsΛࢧ͑ΔࠓͷHashiCorpπʔϧ܈ʹ͍ͭͯ 2018/09/11 ଜ ༡
ೋ ࣇ ͷ ͤ ͍ ͭ ɿ
͓ ͱ ͜ Ϩ ϕ ϧ ɿ ) 1 . 1 ࣾ ձ ਓ ྺ d ɹ % $ Ͱ ࢹ Φϖ Ϩ ʔ λ ʔ d ɹ ג ࣜ ձ ࣾ ɹ ɹ ɹ ɿ 4 : 4 5 & . 0 1 & 3 "50 3 d / 0 8 ɹ ɹ ג ࣜ ձ ࣾ " 1 1 - * # 05 ɿ 4 : 4 5 & . 0 1 & 3 "50 3 ͳ · ͑ ɹ ɹ ɿ ଜ ɹ ༡ ͭ ͍ ͬ ͨ ʔ ɿ !HBDIBSJPO HVNJ ࣗ ݾ հ
גࣜձࣾΞϓϦϘοτ ཱ݄̓ $ZCFS"HFOU εϚʔτϑΥϯήʔϜΤϯλʔςΠϝϯτࣄۀ 4(& ɹͷͷࣾ ήʔϜ͚ͩͰͳ͘ɺΦϯϥΠϯϓϩάϥϛϯάڭҭαʔϏε ϝσΟΞܥͷใൃ৴αΠτӡӦ ձࣾઆ໌
None
None
̍ΞϓϦέʔγϣϯຖʹ Χϯύχʔ੍
ӡ༻தͷΞϓϦ ຊ
৽ن։ൃ1+ /ຊ
ͦͷଞαΠτ࡞Β ৽نࣄۀΒ ΖΖΖ
4:401 αʔόڥΛ༻ҙ͢Δਓ ਓ
ΞϓϦέʔγϣϯνʔϜͷ αʔόΤϯδχΞͱ ڠྗ͢Δ͜ͱ͕ଟ͍
͢͜ͱ w աڈʹ͋ͬͨ՝Λ UFSSBGPSNQBDLFSΛͬͯ Ͳ͏ղফ͔ͨ͠ͱ͍͏͓
͞ͳ͍͜ͱ w ࡉ͔͍5JQT
agenda w DBTF*NBHF࡞ w DBTFෛՙࢼݧڥߏங w DBTF৽نڥߏங w ·ͱΊ
$BTF *NBHF࡞
º º ͏ͷ
Packer • ༻్ • AMI / GCP Image / Container
Imageͷ࡞ • ansibleͱซ༻ͯ͠༻ • ϝϦοτ • Πϝʔδ࡞ͷྲྀΕΛςϯϓϨʔτԽ
before w ྫ"NB[PO".* CBTFͱͳΔ".*͔Β&$ىಈ "OTJCMFͰߏมߋΛద༻ Πϝʔδऔಘͨ͠αʔόͷআ Ҏ্ΛશͯखಈͰ࣮ߦ
before ىಈதʹผͷ࡞ۀΔ ˠΕΔ Πϝʔδऔಘޙͷαʔόআ ˠΕΔ ͦͦ͜ͷ࡞ۀ ˠΊΜͲ͍
ͦΜͳ࣌
after $ p a c k e r b u
i l d p a c k e r . j s o n ʊਓਓਓਓਓਓਓਓਓʊ ʼɹίϚϯυҰൃʂɹʻ ʉ:?:?:?:?:?:?ʉ
JOB
ৄࡉϒϩάͰ ͯͬ͘΅ͬͱ https://blog.applibot.co.jp/ 2018/05/11/how-to-build- aws-ami-in-applibot/
$BTF ෛՙࢼݧߏங
º ͏ͷ
ෛՙࢼݧͷ߹ͷׂ ෛ ՙ ࢼ ݧ Λ ͔ ͚Δ ਓ
γ φ Ϧ Φ ࡞ ࢼ ݧ ࣮ ߦ ݁ Ռ · ͱ Ί ෛ ՙ ࢼ ݧ ڥ Λ ࡞ Δ ਓ ڥ ࡞ ߏ ม ߋ Ϩ Ϗϡ ʔ αʔόΤϯδχΞ γεΦϖ
Α͋͘Δޫܠ ৽ Πϕ ϯ τ ։ ൃ ͠ · ͠
ͨ ʂ ෛ ՙ ࢼ ݧ Γ ͨ ͍Ͱ ͢ ʂ ͍ ͭ · Ͱ ʹ ༻ ҙ Ͱ ͖ · ͢ ͔ ʂ ʁ ͏ ʔ ʔ ʔ ʔ Μ ɻ ࠓ ख ͕ ۭ ͔ ͳ ͍ ͔ Β ʜ ͙ Β ͍Ͱ ʜ ͦ͘ ͓ ͦ ʂ ʢ ྃ ղ Ͱ ͢ ʂ ΑΖ ͠ ͘ ͓ ئ ͍ ͠ · ͢ ʂ ʣ
ӡ༻தͷαʔϏε͕ ෛՙࢼݧΛΔ࣌ w ৽نΠϕϯτϦϦʔεલ w αʔόଆͷߏมߋΛߦ͏࣌ w $.େن13લ
༻ҙ͢Δͷ ΠϯϑϥपΓ w ࠷ऴతʹɺຊ൪ಉͷڥ w ࢼݧͷλΠϛϯάͰ࡞ w ෛՙΛ͔͚Δαʔό w +.FUFSΛ༻
&$ ɻωοτϫʔΫผɻΞΧϯτ͚͍ͯΔ w ֤छϞχλϦϯά w HSBGBOBQSPNFUIFVTLJCBOB FMBTUJDTFBSDI w ͜͜ࠓճؔͳ͠
༻ҙ͢Δͷ ΠϯϑϥपΓ w ࠷ऴతʹɺຊ൪ಉͷڥ w ࠷ॳಉ͡ߏͰখ͍͞ΠϯελϯεΫϥε w ຊ൪ಉͷنͰৗʹҡ࣋͢Δͱɺ අ༻͕ϠόΠͷͰࢼݧͷʹ࡞͢Δ w
ࢼݧظؒதͰɺΘͳ͍ͱ͖খ͘͞
༻ҙ͢Δͷ ΠϯϑϥपΓ w ෛՙΛ͔͚Δαʔό w ฐࣾͰ+.FUFSΛ༻ w NBTUFSTMBWFߏ TMBWF"VUP4DBMJOHͰεέʔϧ͢Δ w
ͪ͜Βࢼݧͷʹ࡞ w Θͳ͍࣌আ
before ཧΠϯελϯεͷBXTDMJΛΰϦΰϦ 3%4&MBTUJ$BDIF&$FUDʜ ىಈॱ൪εΫϦϓτؒͰௐ ग़དྷ্͕ΔൿͷλϨ TZTPQଆͰຖேຖ൩ͷ֦ுॖখରԠ
Կ͔͋Δʁ w Ұಈ͔ͤྑ͍͚Ͳ w ཧ͕େม w ଞϓϩδΣΫτͰ·ͨΰϦΰϦͱ w ҉తͳߏॱ͋ͬͨΓͰ ֮͑ͯΒ͍ͮΒ͍
ͦΜͳ࣌ͦ͜
Ұ͔ΒUFSSBGPSNͰ࡞ w ߏཁૉΛશͯUFSSBGPSNԽ w جຊతʹ࡞Γ͠ w طʹ͋ΔϦιʔε UFSSBGPSNJNQPSU w Ͳ͏ͯ͠߹ੑ߹Θͳ͍ͱ͖
UGTUBUFΛमਖ਼
Կ͕ྑ͘ͳͬͨʁ w ىಈཧͷू͕Ͱ͖ͨ w UFSSBGPSNͷϑΝΠϧΛݟΕɺߏཁૉ͕Θ͔Δঢ়ଶ w ࡞εέʔϧUFSSBGPSNBQQMZͰPL w ߏॱংࢦఆ EFQFOET@PO
w WBSTͷΓସ͑Ͱɺॖখɺ֦ு༰қ
ॖখ༻ ########################## ## Aurora InstanceClass ## ########################## rds_master_class = “db.r3.2xlarge"
################# ## Autoscaling ## ################# desired_capacity = “10” ֦ு༻ ########################## ## Aurora InstanceClass ## ########################## rds_master_class = “db.t2.medium” ################# ## Autoscaling ## ################# desired_capacity = “0” ֦ுॖখWBSTϑΝΠϧͷ Γସ͑ͰରԠ
# ద༻͢ΔvarsΛηοτ vars_file=vars_file/${OPTARG}_value.tfvars # tfstateόοΫΞοϓ if [ ${option} == "apply"
]; then terraform state pull > backup/terraform.tfstate_backup_`date +"%Y-%m-%d-%H-%M- %S"` fi # terraform࣮ߦ (plan or apply) terraform ${tf_option} -var-file=${vars_file} ࣮ߦ༻εΫϦϓτ
w ઃఆ͕ڞ༗Ͱ͖͓ͯΓ w มߋWBSTͷΓସ͑ͰPL w ͱͳͬͨΒɺ͋ͱ୭͕࣮ߦͯ͠ Ұॹ
after ʊਓਓਓਓਓਓਓਓਓʊ ʼɹTMBDLҰൃʂʻ ʉ:?:?:?:?:?:?ʉ hoge hoge hoge
None
after hoge hoge hoge w εέʔϧͷݖݶΛΞϓϦνʔϜҠৡ w Ͳ͏͍͏ڥͰࢼݧ͍ͯ͠Δ͔ͷ ֬ೝ༰қ w
ϘτϧωοΫՕॴͷมߋ WBSTͷΛ͍͡Δ͚ͩͰมߋͰ͖Δ εϐʔυײͷ͋ΔରԠΛ ߦ͏͜ͱ͕Ͱ͖Δ
$BTF ৽نڥߏங
º ࣄྫ
৽نαʔϏεͷڥߏஙͷྲྀΕ ͦ Ζ ͦ Ζ α ʔ ό ͱ ૄ
௨ ͯ͠ ֬ ೝ ͠ ͨ ͍ ͍ ͭ · Ͱ ʹ ༻ ҙ Ͱ ͖ · ͢ ͔ ʂ ʁ Ξ Χ ϯ τ ͔ Β ͷ ༻ ҙ ͩ ͔ Β ɺ ͋ Ε ͍ Εͯ ͜ Ε ͍ Εͯ ͋ ʜ ͙ Β ͍Ͱ ʜ ͦ͘ ͓ ͦ ʂ ʢ ྃ ղ Ͱ ͢ ʂ ΑΖ ͠ ͘ ͓ ئ ͍ ͠ · ͢ ʂ ʣ
before SPPUΞΧϯτͷ෧ҹ $POTPMJEBUFE#JMMJOHઃఆ *".6TFSͷ࡞ɺ(SPVQઃఆɺTXJUDIઃఆ $MPVE5SBJMMPH༻4όέοτͷઃఆ ωοτϫʔΫઃఆɺࢹ༻ϙʔτ։͚ FUD
ͦΜͳઃఆ
Կ͕ྑ͘ͳͬͨʁ w ΞΧϯτࣗମͷઃఆཧ w ແҙࣝʹαʔόڥ ΞϓϦέʔγϣϯؔ࿈ ͷ ཧͱͯ͠༻͍͕ͯͨ͠ɺ "84ͷ΄΅શͯͷαʔϏεཏ͍ͯ͠ΔͷͰɺ $MPVE5SBJM͔Β*".·Ͱɺ
ॳظઃఆΛશͯςϯϓϨԽͰ͖ͨɻ
BQQMJCPUͷUFSSBGPSN ϑΥϧμߏ • 00_base • ΞΧϯτ࡞࣌ʹ࡞͢ΔαʔϏε܈ • CloudTrail /
Route53 / keypair / S3(awsؔ࿈ͷϩά༻) / IAMUser • 01_common / 02_dev / 03_stg / 04_prd • ֤ڥ໊ɻιʔτ༻ʹ൪߸ৼ͍ͬͯΔ • workspaceఘΊ·ͨ͠ • 99_modules • ֤ڥ͕ڞ௨Ͱ༻͢Δઃఆ • ྫ: VPC Network
(JUMBCͰ CBTFSFQPTJUPSZཧ
after SPPUΞΧϯτͷ෧ҹ $POTPMJEBUFE#JMMJOHઃఆ UFSSBGPSN༻*".6TFS࡞ UFSSBGPSN࣮ߦ ͰPL
hoge ઃఆมߋ.3Ͱ ཧͰ͖Δ
·ͱΊ
·ͱΊ w 1BDLFSUFSSBGPSNͰཧ͢Δ͜ͱͰ ཧ͘͢͠ɺڞ༗ՄೳͳΠϯϑϥ w ߏங෦͕ૄ݁߹ʹͳΔ͜ͱͰ JOQVUPVUQVUͷΈ߹Θ͕ͤ༰қ w ఆܕ࡞ۀςϯϓϨԽେࣄ
͝੩ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠