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
Zennのパフォーマンスモニタリングでやっていること
ryosukeigarashi
0
600
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
140
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
170
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
160
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
150
A Tour of Anti-patterns for Functional Programming
guvalif
0
1.6k
複雑なState管理からの脱却
sansantech
PRO
1
180
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
7
740
OCI Vault 概要
oracle4engineer
PRO
0
9.8k
OOM発生時のトラブルシューティング Profilerを活用できるか調査してみた
atsushii
0
170
DynamoDB でスロットリングが発生したとき/when_throttling_occurs_in_dynamodb_short
emiki
0
310
型チェック 速度改善 奮闘記⌛
tocomi
2
280
Featured
See All Featured
Designing the Hi-DPI Web
ddemaree
280
34k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
4 Signs Your Business is Dying
shpigford
180
21k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
Practical Orchestrator
shlominoach
186
10k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Designing for humans not robots
tammielis
250
25k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
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 ఆܕ࡞ۀςϯϓϨԽେࣄ
͝੩ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠