Slide 1

Slide 1 text

applibotͷDevOpsΛࢧ͑Δ terraform/packer DevOpsΛࢧ͑Δࠓ࿩୊ͷHashiCorpπʔϧ܈ʹ͍ͭͯ 2018/09/11 ੢ଜ ༡

Slide 2

Slide 2 text

ೋ ࣇ ͷ ෕ ͤ ͍ ΂ ͭ ɿ ͓ ͱ ͜ Ϩ ϕ ϧ ɿ ) 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 ࣗ ݾ ঺ հ

Slide 3

Slide 3 text

גࣜձࣾΞϓϦϘοτ ೥݄̓೔૑ཱ $ZCFS"HFOU εϚʔτϑΥϯήʔϜΤϯλʔςΠϝϯτࣄۀ 4(& ɹͷ಺ͷࣾ ήʔϜ͚ͩͰͳ͘ɺΦϯϥΠϯϓϩάϥϛϯάڭҭαʔϏε΍ ϝσΟΞܥͷ৘ใൃ৴αΠτ΋ӡӦ ձࣾઆ໌

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

̍ΞϓϦέʔγϣϯຖʹ Χϯύχʔ੍

Slide 7

Slide 7 text

ӡ༻தͷΞϓϦ ຊ

Slide 8

Slide 8 text

৽ن։ൃ1+ /ຊ

Slide 9

Slide 9 text

ͦͷଞαΠτ࡞੒΍Β ৽نࣄۀ΍Β ΋Ζ΋Ζ΋Ζ

Slide 10

Slide 10 text

4:401 αʔό؀ڥΛ༻ҙ͢Δਓ ਓ

Slide 11

Slide 11 text

ΞϓϦέʔγϣϯνʔϜͷ αʔόΤϯδχΞͱ ڠྗ͢Δ͜ͱ͕ଟ͍

Slide 12

Slide 12 text

࿩͢͜ͱ w աڈʹ͋ͬͨ՝୊Λ
 UFSSBGPSNQBDLFSΛ࢖ͬͯ
 Ͳ͏ղফ͔ͨ͠ͱ͍͏͓࿩

Slide 13

Slide 13 text

࿩͞ͳ͍͜ͱ w ࡉ͔͍5JQT

Slide 14

Slide 14 text

agenda w DBTF*NBHF࡞੒ w DBTFෛՙࢼݧ؀ڥߏங w DBTF৽ن؀ڥߏங w ·ͱΊ

Slide 15

Slide 15 text

$BTF *NBHF࡞੒

Slide 16

Slide 16 text

º º ࢖͏΋ͷ

Slide 17

Slide 17 text

Packer • ༻్ • AMI / GCP Image / Container Imageͷ࡞੒ • ansibleͱซ༻ͯ͠࢖༻ • ϝϦοτ • Πϝʔδ࡞੒ͷྲྀΕΛςϯϓϨʔτԽ

Slide 18

Slide 18 text

before w ྫ"NB[PO".* CBTFͱͳΔ".*͔Β&$ىಈ "OTJCMFͰߏ੒มߋΛద༻ Πϝʔδऔಘͨ͠αʔόͷ࡟আ Ҏ্ΛશͯखಈͰ࣮ߦ

Slide 19

Slide 19 text

before ىಈதʹผͷ࡞ۀ΍Δ ˠ๨ΕΔ Πϝʔδऔಘޙͷαʔό࡟আ ˠ๨ΕΔ ͦ΋ͦ΋͜ͷ࡞ۀ ˠΊΜͲ͍

Slide 20

Slide 20 text

ͦΜͳ࣌͸

Slide 21

Slide 21 text

after $ p a c k e r b u i l d p a c k e r . j s o n ʊਓਓਓਓਓਓਓਓਓʊ ʼɹίϚϯυҰൃʂɹʻ ʉ:?:?:?:?:?:?ʉ

Slide 22

Slide 22 text

JOB

Slide 23

Slide 23 text

ৄࡉ͸ϒϩάͰ ͯͬ͘΅ͬͱ https://blog.applibot.co.jp/ 2018/05/11/how-to-build- aws-ami-in-applibot/

Slide 24

Slide 24 text

$BTF ෛՙࢼݧߏங

Slide 25

Slide 25 text

º ࢖͏΋ͷ

Slide 26

Slide 26 text

ෛՙࢼݧͷ৔߹ͷ໾ׂ ෛ ՙ ࢼ ݧ Λ ͔ ͚Δ ਓ γ φ Ϧ Φ ࡞ ੒ ࢼ ݧ ࣮ ߦ ݁ Ռ · ͱ Ί ෛ ՙ ࢼ ݧ ؀ ڥ Λ ࡞ Δ ਓ ؀ ڥ ࡞ ੒ ߏ ੒ ม ߋ Ϩ Ϗϡ ʔ αʔόΤϯδχΞ γεΦϖ

Slide 27

Slide 27 text

Α͋͘Δޫܠ ৽ Πϕ ϯ τ ։ ൃ ͠ · ͠ ͨ ʂ ෛ ՙ ࢼ ݧ ΍ Γ ͨ ͍Ͱ ͢ ʂ ͍ ͭ · Ͱ ʹ ༻ ҙ Ͱ ͖ · ͢ ͔ ʂ ʁ ͏ ʔ ʔ ʔ ʔ Μ ɻ ࠓ ख ͕ ۭ ͔ ͳ ͍ ͔ Β ʜ ೔ ͙ Β ͍Ͱ ʜ ͦ͘ ͓ ͦ ʂ ʢ ྃ ղ Ͱ ͢ ʂ ΑΖ ͠ ͘ ͓ ئ ͍ ͠ · ͢ ʂ ʣ

Slide 28

Slide 28 text

ӡ༻தͷαʔϏε͕ ෛՙࢼݧΛ΍Δ࣌ w ৽نΠϕϯτϦϦʔεલ w αʔόଆͷߏ੒มߋΛߦ͏࣌ w $.౳େن໛13લ

Slide 29

Slide 29 text

༻ҙ͢Δ΋ͷ ΠϯϑϥपΓ w ࠷ऴతʹɺຊ൪ಉ౳ͷ؀ڥ w ࢼݧͷλΠϛϯάͰ࡞੒ w ෛՙΛ͔͚Δαʔό w +.FUFSΛ࢖༻ &$ ɻωοτϫʔΫ͸ผɻΞΧ΢ϯτ෼͚͍ͯΔ w ֤छϞχλϦϯά w HSBGBOBQSPNFUIFVTLJCBOBFMBTUJDTFBSDI w ͜͜͸ࠓճؔ܎ͳ͠

Slide 30

Slide 30 text

༻ҙ͢Δ΋ͷ ΠϯϑϥपΓ w ࠷ऴతʹɺຊ൪ಉ౳ͷ؀ڥ w ࠷ॳ͸ಉ͡ߏ੒Ͱখ͍͞ΠϯελϯεΫϥε w ຊ൪ಉ౳ͷن໛Ͱৗʹҡ࣋͢Δͱɺ
 අ༻͕ϠόΠͷͰࢼݧͷ౓ʹ࡞੒͢Δ w ࢼݧظؒதͰ΋ɺ࢖Θͳ͍ͱ͖͸খ͘͞

Slide 31

Slide 31 text

༻ҙ͢Δ΋ͷ ΠϯϑϥपΓ w ෛՙΛ͔͚Δαʔό w ฐࣾͰ͸+.FUFSΛ࢖༻ w NBTUFSTMBWFߏ੒
 TMBWF͸"VUP4DBMJOHͰεέʔϧ͢Δ w ͪ͜Β΋ࢼݧͷ౓ʹ࡞੒ w ࢖Θͳ͍࣌͸࡟আ

Slide 32

Slide 32 text

before ؅ཧΠϯελϯε෼ͷBXTDMJΛΰϦΰϦ 3%4&MBTUJ$BDIF&$FUDʜ ىಈॱ൪͸εΫϦϓτؒͰௐ੔ ग़དྷ্͕Δൿ఻ͷλϨ TZTPQଆͰຖேຖ൩ͷ֦ுॖখରԠ

Slide 33

Slide 33 text

Կ͔໰୊͋Δʁ w Ұ౓ಈ͔ͤ͹ྑ͍͚Ͳ w ؅ཧ͕େม w ଞϓϩδΣΫτͰ͸·ͨΰϦΰϦͱ w ҉໧తͳߏ੒ॱ΋͋ͬͨΓͰ
 ֮͑ͯ΋Β͍ͮΒ͍

Slide 34

Slide 34 text

ͦΜͳ࣌ͦ͜

Slide 35

Slide 35 text

Ұ͔ΒUFSSBGPSNͰ࡞੒ w ߏ੒ཁૉΛશͯUFSSBGPSNԽ w جຊతʹ͸࡞Γ௚͠ w طʹ͋ΔϦιʔε͸
 UFSSBGPSNJNQPSU w Ͳ͏ͯ͠΋੔߹ੑ߹Θͳ͍ͱ͖͸
 UGTUBUFΛ௚઀मਖ਼

Slide 36

Slide 36 text

Կ͕ྑ͘ͳͬͨʁ w ىಈ؅ཧͷू໿͕Ͱ͖ͨ w UFSSBGPSNͷϑΝΠϧΛݟΕ͹ɺߏ੒ཁૉ͕Θ͔Δঢ়ଶ w ࡞੒΋εέʔϧ΋UFSSBGPSNBQQMZͰPL w ߏ੒ॱং΋ࢦఆ EFQFOET@PO w WBSTͷ੾Γସ͑Ͱɺॖখɺ֦ு΋༰қ

Slide 37

Slide 37 text

ॖখ༻ ########################## ## 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ϑΝΠϧͷ
 ੾Γସ͑ͰରԠ

Slide 38

Slide 38 text

# ద༻͢Δ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} ࣮ߦ༻εΫϦϓτ

Slide 39

Slide 39 text

w ઃఆ͕ڞ༗Ͱ͖͓ͯΓ w มߋ΋WBSTͷ੾Γସ͑ͰPL w ͱͳͬͨΒɺ͋ͱ͸୭͕࣮ߦͯ͠ ΋Ұॹ

Slide 40

Slide 40 text

after ʊਓਓਓਓਓਓਓਓਓʊ ʼɹTMBDLҰൃʂʻ ʉ:?:?:?:?:?:?ʉ hoge hoge hoge

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

after hoge hoge hoge w εέʔϧͷݖݶΛΞϓϦνʔϜ΁Ҡৡ w Ͳ͏͍͏؀ڥͰࢼݧ͍ͯ͠Δ͔ͷ
 ֬ೝ΋༰қ w ϘτϧωοΫՕॴͷมߋ΋
 WBSTͷ஋Λ͍͡Δ͚ͩͰมߋͰ͖Δ εϐʔυײͷ͋ΔରԠΛ
 ߦ͏͜ͱ͕Ͱ͖Δ

Slide 43

Slide 43 text

$BTF ৽ن؀ڥߏங

Slide 44

Slide 44 text

º ࣄྫ

Slide 45

Slide 45 text

৽نαʔϏεͷ؀ڥߏஙͷྲྀΕ ͦ Ζ ͦ Ζ α ʔ ό ͱ ૄ ௨ ͯ͠ ֬ ೝ ͠ ͨ ͍ ͍ ͭ · Ͱ ʹ ༻ ҙ Ͱ ͖ · ͢ ͔ ʂ ʁ Ξ Χ ΢ ϯ τ ͔ Β ͷ ༻ ҙ ͩ ͔ Β ɺ ͋ Ε ͍ Εͯ ͜ Ε ͍ Εͯ ͋ ͹ ͹ ͹ ʜ ೔ ͙ Β ͍Ͱ ʜ ͦ͘ ͓ ͦ ʂ ʢ ྃ ղ Ͱ ͢ ʂ ΑΖ ͠ ͘ ͓ ئ ͍ ͠ · ͢ ʂ ʣ

Slide 46

Slide 46 text

before SPPUΞΧ΢ϯτͷ෧ҹ $POTPMJEBUFE#JMMJOHઃఆ *".6TFSͷ࡞੒ɺ(SPVQઃఆɺTXJUDIઃఆ $MPVE5SBJMMPH༻4όέοτͷઃఆ ωοτϫʔΫઃఆɺ؂ࢹ༻ϙʔτ։͚ FUD

Slide 47

Slide 47 text

ͦΜͳઃఆ΋

Slide 48

Slide 48 text

Կ͕ྑ͘ͳͬͨʁ w ΞΧ΢ϯτࣗମͷઃఆ؅ཧ w ແҙࣝʹαʔό؀ڥ ΞϓϦέʔγϣϯؔ࿈ ͷ ؅ཧͱͯ͠࢖༻͍͕ͯͨ͠ɺ
 "84ͷ΄΅શͯͷαʔϏε໢ཏ͍ͯ͠ΔͷͰɺ
 $MPVE5SBJM͔Β*".·Ͱɺ
 ॳظઃఆΛશͯςϯϓϨԽͰ͖ͨɻ

Slide 49

Slide 49 text

BQQMJCPUͷUFSSBGPSN ϑΥϧμߏ੒ • 00_base • ΞΧ΢ϯτ࡞੒࣌ʹ࡞੒͢ΔαʔϏε܈ • CloudTrail / Route53 / keypair / S3(awsؔ࿈ͷϩά༻) / IAMUser • 01_common / 02_dev / 03_stg / 04_prd • ֤؀ڥ໊ɻιʔτ༻ʹ൪߸ৼ͍ͬͯΔ • workspace͸ఘΊ·ͨ͠ • 99_modules • ֤؀ڥ͕ڞ௨Ͱ࢖༻͢Δઃఆ • ྫ: VPC Network

Slide 50

Slide 50 text

(JUMBCͰ CBTFSFQPTJUPSZ؅ཧ

Slide 51

Slide 51 text

after SPPUΞΧ΢ϯτͷ෧ҹ $POTPMJEBUFE#JMMJOHઃఆ UFSSBGPSN༻*".6TFS࡞੒ UFSSBGPSN࣮ߦ ͰPL

Slide 52

Slide 52 text

hoge ઃఆมߋ΋.3Ͱ ؅ཧͰ͖Δ

Slide 53

Slide 53 text

·ͱΊ

Slide 54

Slide 54 text

·ͱΊ w 1BDLFSUFSSBGPSNͰ؅ཧ͢Δ͜ͱͰ
 ؅ཧ͠΍͘͢ɺڞ༗ՄೳͳΠϯϑϥ΁ w ߏங෦෼͕ૄ݁߹ʹͳΔ͜ͱͰ
 JOQVUPVUQVUͷ૊Έ߹Θ͕ͤ༰қ w ఆܕ࡞ۀ͸ςϯϓϨԽେࣄ

Slide 55

Slide 55 text

͝੩ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠