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.3k
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
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
7
700
Lambda10周年!Lambdaは何をもたらしたか
smt7174
2
130
VideoMamba: State Space Model for Efficient Video Understanding
chou500
0
200
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
120
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
160
Engineer Career Talk
lycorp_recruit_jp
0
200
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
130
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
200
AWS Lambda のトラブルシュートをしていて思うこと
kazzpapa3
2
200
【LT】ソフトウェア産業は進化しているのか? #Agilejapan
takabow
0
110
Mastering Quickfix
daisuzu
1
270
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
190
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Building Adaptive Systems
keathley
38
2.3k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Facilitating Awesome Meetings
lara
50
6.1k
Site-Speed That Sticks
csswizardry
0
36
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Building Your Own Lightsaber
phodgson
103
6.1k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Embracing the Ebb and Flow
colly
84
4.5k
The Language of Interfaces
destraynor
154
24k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
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 ఆܕ࡞ۀςϯϓϨԽେࣄ
͝੩ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠