Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CircleCI 2.1の機能を使って、インフラの"ほぼ"全自動構成管理をやってみた話 / circleci-terraform

Kohei Ota
April 23, 2019

CircleCI 2.1の機能を使って、インフラの"ほぼ"全自動構成管理をやってみた話 / circleci-terraform

Kohei Ota

April 23, 2019
Tweet

More Decks by Kohei Ota

Other Decks in Technology

Transcript

  1. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    ୈճ$JSDMF$*ϢʔβʔίϛϡχςΟϛʔτΞοϓ
    גࣜձࣾ;0;0ςΫϊϩδʔζ
    ։ൃ෦43&νʔϜ
    ଠాߤฏ
    $JSDMF$*ͷػೳΛ࢖ͬͯ
    Πϯϑϥͷz΄΅zશࣗಈߏ੒؅ཧΛ΍ͬͯΈͨ࿩

    View full-size slide

  2. ϓϩϑΟʔϧ
    43&νʔϜॴଐͷӳޠŧŔŕŪũƄŝſΠϯϑϥΤϯδχΞ

    "84΍($1্ʹͯࣾ಺Ͱ৽نҊ݅Ͱ࢖͏ͨΊͷٕज़ελοΫͷ
    ௐࠪɺݕ౼ɺ࣮૷͔Βඞཁ͕͋Ε͹ઃܭͳͲ΋୲౰

    ޷͖ͳݴޠ͸ӳޠͱ%PDLFSGJMF

    $JSDMF$*Ͱ%PDLFSͷ͕࢖͑ΔΑ͏ʹͳͬͯخ͍͠ʂʂ

    ࠷ۙ͸5FSSBGPSN(,&ͳͲΛ΍ΓͭͭɺҰൠͷ͝ՈఉʹͳΒ

    Ͳ͜ʹͰ΋͋Δ͓͏ͪ,VCFSOFUFTΛߏஙͨ͠Γ͍ͯ͠Δ
    ;0;0ςΫϊϩδʔζ
    ։ൃ෦43&νʔϜ
    ଠాߤฏ
    Copyright © ZOZO Technologies, Inc. All Rights Reserved.

    View full-size slide

  3. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    ˓೔ຊ࠷େڃͷϑΝογϣϯγϣοϐϯάαΠτΞϓϦ
    ˓ Ҏ্ͷγϣοϓɺ Ҏ্ͷϒϥϯυͷऔΓѻ͍ʢ
    ೥݄຤࣌఺ʣ
    ˓ৗ࣌ສ఺Ҏ্ͷ঎඼ΞΠςϜ਺ͱຖ೔ฏۉ ఺Ҏ্ͷ৽ண঎
    ඼Λܝࡌ
    ˓ଈ೔഑ૹαʔϏεΪϑτϥοϐϯάαʔϏεπέ෷͍ͳͲ
    IUUQT[P[PKQ

    View full-size slide

  4. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    ˓೔ຊ࠷େڃͷϑΝογϣϯίʔσΟωʔτΞϓϦ
    ˓ ສμ΢ϯϩʔυಥഁɺίʔσΟωʔτ౤ߘ૯਺͸ສ݅Ҏ
    ্ʢͱ΋ʹ೥݄຤࣌఺ʣ
    ˓શੈքʢ"QQ4UPSF(PPHMFQMBZ͕ར༻ՄೳͳશͯͷࠃʣͰμ
    ΢ϯϩʔυ͕Մೳ
    ˓ສਓҎ্ͷϑΥϩϫʔΛ࣋ͭϢʔβʔʢ8&"3*45"ʣ΋஀ੜ
    IUUQTXFBSKQ

    View full-size slide

  5. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    ˓౰͕ࣾಠࣗʹ։ൃͨ͠࠾ੇ༻ϘσΟʔεʔπ
    ˓શମʹࢪ͞ΕͨυοτϚʔΧʔΛεϚʔτϑΥϯΧϝϥͰ౓ࡱ
    Ө͢Δ͜ͱͰɺମܕσʔλΛܭଌ
    ˓ܭଌͨ͠ମܕσʔλ͸ɺॠ࣌ʹ%ϞσϧԽ͞Εɺ;0;0508/Ξ
    ϓϦʹอଘɻ%Ϟσϧ͸͋ΒΏΔ֯౓ʹಈ͔͢͜ͱ͕Ͱ͖ɺମܕΛ
    ౓νΣοΫ͢Δ͜ͱ͕Մೳ
    IUUQT[P[PKQ[P[PTVJU

    View full-size slide

  6. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    ˓ʮ;0;046*5ʯͰܭଌͨ͠ମܕσʔλΛ΋ͱʹɺҰਓͻͱΓͷମ
    ܕʹ߹ͬͨʮ͋ͳͨαΠζʯͷΞΠςϜ
    ˓ʮڀۃͷϑΟοτײʯΛ࣮ݱͨ͠ϕʔγοΫΞΠςϜΛఏڙ
    άϩʔόϧαΠτʮ;0;0DPNʯͰւ֎ల։
    ˓ΞΠςϜ̩γϟπɺσχϜύϯπɺγϟπɺϏδωεεʔπɺ
    ωΫλΠɺϘʔμʔ̩γϟπɺ௕କΫϧʔωοΫ̩γϟπͳͲ
    IUUQT[P[PKQNFOCSBOE[P[P

    View full-size slide

  7. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    ࠓ೔࿩͢͜ͱ
    ɾΠϯϑϥߏ੒؅ཧࣗಈԽͷಈػ
    ɾશମͷΞʔΩςΫνϟ
    ɾ$JSDMF$*ͷ৽ػೳʹ͍ͭͯ
    ɾ৽ػೳΛ࢖ͬͯ%3:ʹXPSLGMPXΛॻ͘

    View full-size slide

  8. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    Πϯϑϥߏ੒؅ཧࣗಈԽͷಈػ

    View full-size slide

  9. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    Πϯϑϥߏ੒؅ཧࣗಈԽͷಈػ
    ɾ৽نϓϩδΣΫτͰॳΊͯ($1Λ࢖ͬͨຊ֨తͳΠϯϑϥΛ૊Ή͜ͱʹ
    ɾ5FSSBGPSN࢖ͬͨ͜ͱ͋Δਓ͕গͳ͔ͬͨ
    ɾઃܭͲ͏͠Α͏ʁ
    ɾ൓өͷλΠϛϯάશ෦खͰ΍Δͷා͍ͭ͠Β͍ͷͰࣗಈԽ͍ͨ͠ΑͶ

    View full-size slide

  10. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    શମͷΞʔΩςΫνϟ

    View full-size slide

  11. Copyright © ZOZO Technologies, Inc. All Rights Reserved.

    View full-size slide

  12. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    શମͷΞʔΩςΫνϟͷϙΠϯτ
    ɾ5FSSBGPSNͷCBDLFOEػೳΛ࢖ͬͯ؀ڥ͝ͱʹεςʔτΛ෼཭
    ɾεςʔτϑΝΠϧ͸ΦϒδΣΫτετϨʔδ ($4
    ʹอଘ
    ɾ$JSDMF$*ͷQBSBNFUFSΛ༻͍ͯɺϫʔΫϑϩʔΛ౷ҰԽ
    ɾQBSBNFUFSͰ౷ҰͰ͖ͨδϣϒΛɺFYFDVUPSɺDPNNBOEΛ࢖ͬͯ
    పఈతʹڞ௨Խ
    ɾ.BOVBM"QQSPWBMΛ࢖ͬͨ؀ڥͷ൓ө

    View full-size slide

  13. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    $JSDMF$*ͷ৽ػೳʹ͍ͭͯ

    View full-size slide

  14. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    $JSDMF$*ͷ৽ػೳʹ͍ͭͯ
    ɾFYFDVUPS
    ɾDPNNBOE
    ɾQBSBNFUFS
    ɾPSC

    View full-size slide

  15. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    $JSDMF$*ͷ৽ػೳʹ͍ͭͯ
    ɾFYFDVUPS
    ɾDPNNBOE
    ɾQBSBNFUFS
    ɾPSCࠓճ͸ະ࢖༻

    View full-size slide

  16. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    $JSDMF$*ͷ৽ػೳʹ͍ͭͯ
    ɾFYFDVUPSˡ
    ɾDPNNBOE
    ɾQBSBNFUFS
    ɾPSCࠓճ͸ະ࢖༻

    View full-size slide

  17. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    FYFDVUPS
    ɾʮ࣮ߦ؀ڥʯΛఆٛ͢Δػೳ
    ɾEPDLFSNBDIJOFNBDPTͳͲ͕બ୒Մ
    ɾγΣϧͷछྨɺXPSLJOHEJSFDUPSZͳͲ΋ઃఆͰ͖Δ

    View full-size slide

  18. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    FYFDVUPS

    View full-size slide

  19. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    FYFDVUPS

    View full-size slide

  20. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    ࣮ߦ؀ڥͷఆٛΛίϯϙʔωϯτԽͰ͖Δʂ

    View full-size slide

  21. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    DPNNBOE
    ɾʮεςοϓʯΛఆٛͰ͖Δػೳ
    ɾ֤δϣϒͰڞ௨࣮ͯ͠ߦ͍ͤͨ͞ίϚϯυͳͲΛศརʹݺͼग़ͤΔ

    View full-size slide

  22. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    DPNNBOE

    View full-size slide

  23. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    DPNNBOE

    View full-size slide

  24. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    ࣮ߦδϣϒΛίϯϙʔωϯτԽͰ͖Δʂ

    View full-size slide

  25. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    $JSDMF$*ͷ৽ػೳʹ͍ͭͯ
    ɾFYFDVUPS
    ɾDPNNBOE
    ɾQBSBNFUFSˡ
    ɾPSCࠓճ͸ະ࢖༻

    View full-size slide

  26. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    QBSBNFUFS
    ɾZBNMͷதͰ࢖͑Δʮม਺ʯͷఆٛ
    ɾࠓճ͸ɺ؀ڥͷৼΓ෼͚ʹར༻͍ͯ͠Δ

    View full-size slide

  27. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    QBSBNFUFS

    View full-size slide

  28. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    QBSBNFUFS

    View full-size slide

  29. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    ม਺ΛίϯϙʔωϯτԽͰ͖Δʂ

    View full-size slide

  30. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    5FSSBGPSNͱ$*ͷઃܭํ਑

    View full-size slide

  31. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    5FSSBGPSNͱ$*ͷઃܭํ਑
    ɾ5FSSBGPSNʹىͤ͜Δ΋ͷΛۃྗίʔυԽ͢Δ
    ɾ؀ڥґଘΛͳͯ͘͠%3:ʹॻ͘
    ɾखಈͷΦϖϨʔγϣϯΛۃྗݮΒ͢
    ɾ։ൃऀͰ΋खؒΛগͳ͘มߋ͕͔͚ΒΕΔΑ͏ʹ͢Δ

    View full-size slide

  32. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    5FSSBGPSNͱ$*ͷઃܭํ਑
    ɾ5FSSBGPSNʹىͤ͜Δ΋ͷΛۃྗίʔυԽ͢Δ
    ˠؤுͬͨʢؤுͬͨʣ

    View full-size slide

  33. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    5FSSBGPSNͱ$*ͷઃܭํ਑
    ɾ؀ڥґଘΛͳͯ͘͠%3:ʹॻ͘
    ˠ5FSSBGPSNͷUGWBSTͱɺ$JSDMF$*ͷQBSBNFUFSΛར༻
    ˠ5FSSBGPSNͰ࢖͏ม਺Λ$*͔Β౉͞ΕΔม਺ͰಈతʹಡΈࠐΈ
    ˠશମͷXPSLGMPXΛపఈతʹશ؀ڥͰ౷ҰԽͰ͖ͨ
    NBJOUG ؀ڥ͝ͱʹڞ௨

    QSEUGWBST NBTUFS
    TUHUGWBST TUBHJOH

    ɾϓϩδΣΫτ໊
    ɾϦʔδϣϯ
    ɾΠϯελϯελΠϓͳͲ
    ɾϓϩδΣΫτ໊
    ɾϦʔδϣϯ
    ɾΠϯελϯελΠϓͳͲ

    View full-size slide

  34. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    5FSSBGPSNͱ$*ͷઃܭํ਑
    ɾखಈͷΦϖϨʔγϣϯΛۃྗݮΒ͢
    ˠ5FSSBGPSNͷQMBO͔ΒBQQMZ·ͰΛɺશͯ$*্Ͱ׬݁
    ˠਓͷखʹΑΔ"QQMZΛͤ͞ͳ͍࢓૊Έͮ͘Γ

    View full-size slide

  35. Copyright © ZOZO Technologies, Inc. All Rights Reserved.

    View full-size slide

  36. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    ࣗಈԽͷൣғ

    View full-size slide

  37. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    ͱ͸͍͑ɺΠϯϑϥͷߏ੒มߋΛ
    ࣗಈͰద༻ͯ͠΋͍͍ͷ͔ʁ

    View full-size slide

  38. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    .BOVBM"QQSPWBMΛ࢖͏

    View full-size slide

  39. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    .BOVBM"QQSPWBM
    ɾ$JSDMF$*͔Β͍ͭͨɺ$*ͷεςοϓΛखಈঝೝͤ͞Δػೳ
    ɾ$*ͷը໘ʢ·ͨ͸4MBDL௨஌ͳͲʣ͔Βɺਓؒͷ໨ΛೖΕͯ
    ֬ೝ͍ͤͨ͞৔߹ͳͲʹ༻͍Δ͜ͱ͕Ͱ͖Δ

    View full-size slide

  40. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    ࠷ޙͷ·ͱΊ

    View full-size slide

  41. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    ·ͱΊ
    ɾDPNNBOEFYFDVUPSQBSBNFUFSΛ࢖ͬͯɺͦΕͧΕ༷ʑͳఆٛΛ
    ίϯϙʔωϯτԽͰ͖ΔΑ͏ʹͳͬͨ
    ɾ؀ڥ͝ͱʹಉҰͷ͜ͱΛͤ͞Δ৔߹͸ɺQBSBNFUFSXPSLGMPX͕ศར
    ɾ*OGSBTUSVDUVSFBT$PEFͷ$*$%ʹ͓͍ͯ͸ɺԿΛࣗಈԽ͢Δ͔Λ
    ఆΊΔ͜ͱ͕ॏཁ
    ɾ.BOVBM"QQSPWBMʹΑͬͯʮ͋͑ͯʯਓͷखΛհ͢͜ͱͰ
    कΔ΂͖΋ͷΛकΔz΄΅zશࣗಈͳߏ੒Λ࡞Δ͜ͱ͕Ͱ͖ͨ

    View full-size slide

  42. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    $JSDMF$*Λ࢖ͬͯɺ%3:Ͱૉఢͳ$*ϥΠϑΛʂ

    View full-size slide

  43. Copyright © ZOZO Technologies, Inc. All Rights Reserved.
    ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ

    View full-size slide