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

Ad22fcf5773b906c08330f4d57242212?s=47 Kohei Ota
April 23, 2019

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

Ad22fcf5773b906c08330f4d57242212?s=128

Kohei Ota

April 23, 2019
Tweet

Transcript

  1. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ୈճ$JSDMF$*ϢʔβʔίϛϡχςΟϛʔτΞοϓ גࣜձࣾ;0;0ςΫϊϩδʔζ

    ։ൃ෦43&νʔϜ ଠాߤฏ $JSDMF$*ͷػೳΛ࢖ͬͯ Πϯϑϥͷz΄΅zશࣗಈߏ੒؅ཧΛ΍ͬͯΈͨ࿩
  2. ϓϩϑΟʔϧ 43&νʔϜॴଐͷӳޠŧŔŕŪũƄŝſΠϯϑϥΤϯδχΞ
 "84΍($1্ʹͯࣾ಺Ͱ৽نҊ݅Ͱ࢖͏ͨΊͷٕज़ελοΫͷ ௐࠪɺݕ౼ɺ࣮૷͔Βඞཁ͕͋Ε͹ઃܭͳͲ΋୲౰
 ޷͖ͳݴޠ͸ӳޠͱ%PDLFSGJMF
 $JSDMF$*Ͱ%PDLFSͷ͕࢖͑ΔΑ͏ʹͳͬͯخ͍͠ʂʂ
 ࠷ۙ͸5FSSBGPSN (,&ͳͲΛ΍ΓͭͭɺҰൠͷ͝ՈఉʹͳΒ
 Ͳ͜ʹͰ΋͋Δ͓͏ͪ,VCFSOFUFTΛߏஙͨ͠Γ͍ͯ͠Δ ;0;0ςΫϊϩδʔζ

    ։ൃ෦43&νʔϜ ଠాߤฏ Copyright © ZOZO Technologies, Inc. All Rights Reserved.
  3. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ˓೔ຊ࠷େڃͷϑΝογϣϯγϣοϐϯάαΠτΞϓϦ ˓

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

    ສμ΢ϯϩʔυಥഁɺίʔσΟωʔτ౤ߘ૯਺͸ສ݅Ҏ ্ʢͱ΋ʹ೥݄຤࣌఺ʣ ˓શੈքʢ"QQ4UPSF(PPHMFQMBZ͕ར༻ՄೳͳશͯͷࠃʣͰμ ΢ϯϩʔυ͕Մೳ ˓ສਓҎ্ͷϑΥϩϫʔΛ࣋ͭϢʔβʔʢ8&"3*45"ʣ΋஀ੜ IUUQTXFBSKQ
  5. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ˓౰͕ࣾಠࣗʹ։ൃͨ͠࠾ੇ༻ϘσΟʔεʔπ ˓શମʹࢪ͞ΕͨυοτϚʔΧʔΛεϚʔτϑΥϯΧϝϥͰ౓ࡱ

    Ө͢Δ͜ͱͰɺମܕσʔλΛܭଌ ˓ܭଌͨ͠ମܕσʔλ͸ɺॠ࣌ʹ%ϞσϧԽ͞Εɺ;0;0508/Ξ ϓϦʹอଘɻ%Ϟσϧ͸͋ΒΏΔ֯౓ʹಈ͔͢͜ͱ͕Ͱ͖ɺମܕΛ ౓νΣοΫ͢Δ͜ͱ͕Մೳ IUUQT[P[PKQ[P[PTVJU
  6. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ˓ʮ;0;046*5ʯͰܭଌͨ͠ମܕσʔλΛ΋ͱʹɺҰਓͻͱΓͷମ ܕʹ߹ͬͨʮ͋ͳͨαΠζʯͷΞΠςϜ

    ˓ʮڀۃͷϑΟοτײʯΛ࣮ݱͨ͠ϕʔγοΫΞΠςϜΛఏڙ άϩʔόϧαΠτʮ;0;0DPNʯͰւ֎ల։ ˓ΞΠςϜ̩γϟπɺσχϜύϯπɺγϟπɺϏδωεεʔπɺ ωΫλΠɺϘʔμʔ̩γϟπɺ௕କΫϧʔωοΫ̩γϟπͳͲ IUUQT[P[PKQNFOCSBOE[P[P
  7. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ࠓ೔࿩͢͜ͱ ɾΠϯϑϥߏ੒؅ཧࣗಈԽͷಈػ

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

  9. Copyright © ZOZO Technologies, Inc. All Rights Reserved. Πϯϑϥߏ੒؅ཧࣗಈԽͷಈػ ɾ৽نϓϩδΣΫτͰॳΊͯ($1Λ࢖ͬͨຊ֨తͳΠϯϑϥΛ૊Ή͜ͱʹ

    ɾ5FSSBGPSN࢖ͬͨ͜ͱ͋Δਓ͕গͳ͔ͬͨ ɾઃܭͲ͏͠Α͏ʁ ɾ൓өͷλΠϛϯάશ෦खͰ΍Δͷා͍ͭ͠Β͍ͷͰࣗಈԽ͍ͨ͠ΑͶ
  10. Copyright © ZOZO Technologies, Inc. All Rights Reserved. શମͷΞʔΩςΫνϟ

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

  12. Copyright © ZOZO Technologies, Inc. All Rights Reserved. શମͷΞʔΩςΫνϟͷϙΠϯτ ɾ5FSSBGPSNͷCBDLFOEػೳΛ࢖ͬͯ؀ڥ͝ͱʹεςʔτΛ෼཭

    ɾεςʔτϑΝΠϧ͸ΦϒδΣΫτετϨʔδ ($4 ʹอଘ ɾ$JSDMF$*ͷQBSBNFUFSΛ༻͍ͯɺϫʔΫϑϩʔΛ౷ҰԽ ɾQBSBNFUFSͰ౷ҰͰ͖ͨδϣϒΛɺFYFDVUPSɺDPNNBOEΛ࢖ͬͯ పఈతʹڞ௨Խ ɾ.BOVBM"QQSPWBMΛ࢖ͬͨ؀ڥͷ൓ө
  13. Copyright © ZOZO Technologies, Inc. All Rights Reserved. $JSDMF$*ͷ৽ػೳʹ͍ͭͯ

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

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

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

    ɾDPNNBOE ɾQBSBNFUFS ɾPSCࠓճ͸ະ࢖༻
  17. Copyright © ZOZO Technologies, Inc. All Rights Reserved. FYFDVUPS ɾʮ࣮ߦ؀ڥʯΛఆٛ͢Δػೳ

    ɾEPDLFSNBDIJOFNBDPTͳͲ͕બ୒Մ ɾγΣϧͷछྨɺXPSLJOHEJSFDUPSZͳͲ΋ઃఆͰ͖Δ
  18. Copyright © ZOZO Technologies, Inc. All Rights Reserved. FYFDVUPS

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

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

  21. Copyright © ZOZO Technologies, Inc. All Rights Reserved. DPNNBOE ɾʮεςοϓʯΛఆٛͰ͖Δػೳ

    ɾ֤δϣϒͰڞ௨࣮ͯ͠ߦ͍ͤͨ͞ίϚϯυͳͲΛศརʹݺͼग़ͤΔ
  22. Copyright © ZOZO Technologies, Inc. All Rights Reserved. DPNNBOE

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

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

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

    ɾDPNNBOE ɾQBSBNFUFSˡ ɾPSCࠓճ͸ະ࢖༻
  26. Copyright © ZOZO Technologies, Inc. All Rights Reserved. QBSBNFUFS ɾZBNMͷதͰ࢖͑Δʮม਺ʯͷఆٛ

    ɾࠓճ͸ɺ؀ڥͷৼΓ෼͚ʹར༻͍ͯ͠Δ
  27. Copyright © ZOZO Technologies, Inc. All Rights Reserved. QBSBNFUFS

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

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

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

  31. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 5FSSBGPSNͱ$*ͷઃܭํ਑ ɾ5FSSBGPSNʹىͤ͜Δ΋ͷΛۃྗίʔυԽ͢Δ

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

    ˠؤுͬͨʢؤுͬͨʣ
  33. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 5FSSBGPSNͱ$*ͷઃܭํ਑ ɾ؀ڥґଘΛͳͯ͘͠%3:ʹॻ͘

    ˠ5FSSBGPSNͷUGWBSTͱɺ$JSDMF$*ͷQBSBNFUFSΛར༻ ˠ5FSSBGPSNͰ࢖͏ม਺Λ$*͔Β౉͞ΕΔม਺ͰಈతʹಡΈࠐΈ ˠશମͷXPSLGMPXΛపఈతʹશ؀ڥͰ౷ҰԽͰ͖ͨ NBJOUG ؀ڥ͝ͱʹڞ௨ QSEUGWBST NBTUFS TUHUGWBST TUBHJOH ɾϓϩδΣΫτ໊ ɾϦʔδϣϯ ɾΠϯελϯελΠϓͳͲ ɾϓϩδΣΫτ໊ ɾϦʔδϣϯ ɾΠϯελϯελΠϓͳͲ
  34. Copyright © ZOZO Technologies, Inc. All Rights Reserved. 5FSSBGPSNͱ$*ͷઃܭํ਑ ɾखಈͷΦϖϨʔγϣϯΛۃྗݮΒ͢

    ˠ5FSSBGPSNͷQMBO͔ΒBQQMZ·ͰΛɺશͯ$*্Ͱ׬݁ ˠਓͷखʹΑΔ"QQMZΛͤ͞ͳ͍࢓૊Έͮ͘Γ
  35. Copyright © ZOZO Technologies, Inc. All Rights Reserved.

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

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

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

  39. Copyright © ZOZO Technologies, Inc. All Rights Reserved. .BOVBM"QQSPWBM ɾ$JSDMF$*͔Β͍ͭͨɺ$*ͷεςοϓΛखಈঝೝͤ͞Δػೳ

    ɾ$*ͷը໘ʢ·ͨ͸4MBDL௨஌ͳͲʣ͔Βɺਓؒͷ໨ΛೖΕͯ ֬ೝ͍ͤͨ͞৔߹ͳͲʹ༻͍Δ͜ͱ͕Ͱ͖Δ
  40. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ࠷ޙͷ·ͱΊ

  41. Copyright © ZOZO Technologies, Inc. All Rights Reserved. ·ͱΊ ɾDPNNBOEFYFDVUPSQBSBNFUFSΛ࢖ͬͯɺͦΕͧΕ༷ʑͳఆٛΛ

    ίϯϙʔωϯτԽͰ͖ΔΑ͏ʹͳͬͨ ɾ؀ڥ͝ͱʹಉҰͷ͜ͱΛͤ͞Δ৔߹͸ɺQBSBNFUFS XPSLGMPX͕ศར ɾ*OGSBTUSVDUVSFBT$PEFͷ$*$%ʹ͓͍ͯ͸ɺԿΛࣗಈԽ͢Δ͔Λ ఆΊΔ͜ͱ͕ॏཁ ɾ.BOVBM"QQSPWBMʹΑͬͯʮ͋͑ͯʯਓͷखΛհ͢͜ͱͰ कΔ΂͖΋ͷΛकΔz΄΅zશࣗಈͳߏ੒Λ࡞Δ͜ͱ͕Ͱ͖ͨ
  42. Copyright © ZOZO Technologies, Inc. All Rights Reserved. $JSDMF$*Λ࢖ͬͯɺ%3:Ͱૉఢͳ$*ϥΠϑΛʂ

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