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

Mackerel におけるTerraform 運用 / Our (Best?) Practice

heleeen
July 02, 2020

Mackerel におけるTerraform 運用 / Our (Best?) Practice

heleeen

July 02, 2020
Tweet

More Decks by heleeen

Other Decks in Technology

Transcript

  1. /CEMGTGN䛸䜽䝷䜴䝗 Ɣ 0FBୖ䛷✌ാ䛧䛶䛔䜛 ż ᪥䚻䛾㐠⏝䛸䛧䛶䛿0FB䛜䝯䜲䞁 Ɣ 0FB̾0d_\N䜲䞁䝔䜾䝺䞊䝅䝵䞁ͅ62?䜲䞁䝔䜾䝺䞊䝅䝵䞁˟௒ኟˠ ż ௒ኟ*&3䜲䞁䝔䜾䝺䞊䝅䝵䞁䜢䝸䝸䞊䝇䛧䜎䛩 ż

    0d_\N̾62?䛾䝸䝋䞊䝇䜒ᢅ䛳䛶䛔䛖䜛 Ɣ 䝗䝑䜾䝣䞊䝕䜱䞁䜾ᩥ໬ ż ┘ど䜔<JLUN\NV䛷䛾䝥䝷䜽䝔䜱䝇䜢ᥦ౪䛧䛶䛔䛝䛯䛔 Ɣ ᢅ䛖⠊ᅖ䛜ᗈ䛟˳䛭䛾ᴗ⏺䛾ኚ໬䜒㏿䛔
  2. 9J[PQV6GTTCHQTO4GIKUVT[" Ɣ 䛭䛾䜋䛖䛜ᑐᛂ䛜㏿䛔䛸ุ᩿䛧䛯 ż ᚲせ䛺䜒䛾䜢ᚲせ䛺༢఩䛷䛭䜝䛘䛯䛔 Ŷ ᚲせ䛺༢఩ ౑⏝䛧䛶䛔䜛䝃䞊䝡䝇䛾䜎䛸䜎䜚 Ŷ /CEMGTGN䛾ᇶ┙䜢⟶⌮䛩䜛䛯䜑䛾6GTTCHQTO/QFWNG䜢స䛳䛶䛔䛟

    Ɣ 䛭䜜䜘䜚ᗈ䛔⠊ᅖ䛿⪃៖䛧䛺䛔 ż ධ䜜䛶䛚䛝䛯䛔タᐃ䜢䝕䝣䜷䝹䝖್䜔ᚲ㡲䛻䛷䛝䜛 Ŷ ࿨ྡつ๎䝁䝇䝖㞟ィ䛾䛯䜑䛾䝍䜾 ż 6GTTCHQTO䜔2TQXKFGT䜽䝷䜴䝗䛾᪂ᶵ⬟䛻⣲᪩䛟㏣ᚑ䛧䛶䛔䛝䛯䛔
  3. 9J[PQV6GTTCHQTO4GIKUVT[" Ɣ ⮬ศ䛷స䜛䛾䛜ዲ䛝䛺ே䛯䛱䛜㞟䜎䛳䛶䛔䜛఍♫ ż ⮬స䛩䜛䜋䛖䛜䜘䛥䛭䛖䛸ุ᩿䛩䜛䛸 䝇䝮䞊䝈䛻ື䛔䛶䛔䛡䜛 ż 6GTTCHQTOᴦ䛧䛔䛧ᡭ䜢ື䛛䛧䛶⩦ᚓ䛧䛯䛔䜘䛽 Ɣ 䛾䛱䛾䛱䛾ุ᩿䜢⊃䜑䛺䛔

    ż 㠀ඹ㏻໬䜒6GTTCHQTO4GIKUVT[䜈䜒⛣⾜䛧䜔䛩䛔 ż 6GTTCHQTO䛾䜘䛔䛸䛣䜝䛾䠍䛴 Ɣ 6GTTCHQTO4GIKUVT[䛾䜋䛖䛜&Ͳ䝒䞊䝹䛻஌䛫䜔䛩䛛䛳䛯䛛䜒䛧䜜䛺䛔 ż 2TKXCVG4GRQUKVQT[䛿ᶒ㝈䛜㞴䛧䛔䛽
  4. ไ⣙䛜䜣䜀䜙䛺䛔 Ɣ ↓⌮䛻ඹ㏻໬䛧䛺䛔 Ɣ N˰Q˰0WJdYX42B_]SXQ5J\QJ^NY\42 ˺ ż ;J_XLR^cZN䛷䝰䝆䝳䞊䝹䜢䜟䛡䜛 ż 5J\QJ^N䛛42

    䛛䛷タᐃ䛧䛯䛔ෆᐜ䛜㐪䛖䛿䛪 ż 䝣䝷䜾䛷」㞧໬䛥䛫䜛䜘䜚䜟䛡䛶᭦᪂䛧䜔䛩䛟
  5. ␒኱஦䛺ไ⣙ Ɣ 䛜䜣䜀䜙䛺䛔 ż ඹ㏻໬䛿౽฼䛰䛡䛹䛩䜜䜀䛩䜛䜋䛹Ⰻ䛔䜟䛡䛷䜒䛺䛔 Ŷ 䛜䜣䜀䛳䛶ඹ㏻໬䛥䛫䜘䛖䛸䛧䛶」㞧໬䛧䛶䜋䛧䛟䛺䛔 ż ᫬䛻䛿ඹ㏻໬䛧䛺䛔䛣䛸䜢㑅ᢥ䛩䜛 Ŷ

    ௒䛿䝇䝢䞊䝗ឤ䛾䜋䛖䛜ඃඛ䛥䜜䛶䛔䜛䛛䜙 Ŷ 䝁䞊䝗䛾ぢ㏻䛧䛿ᝏ䛟䛺䜛䛛䜒䛧䜜䛺䛔 Ŷ ᐇ䛿ᶍ⣴୰䛺䛸䛣䜝䛷䜒䛒䜛 ż 6GTTCHQTO䛿䝸䝣䜯䜽䝍䝸䞁䜾䛧䜔䛩䛔
  6. ไ⣙䝍䜾䛿ᚲ㡲 Ɣ 6GTTCHQTO/QFWNG䛾◚ቯⓗኚ᭦䜢Ẽව䛽䛺䛟⾜䛘䜛䜘䛖䛻 ż ◚ቯⓗኚ᭦䛿Ẽ䜢䛴䛡䛶䛔䛶䜒㉳䛣䛳䛶䛧䜎䛖 ż 䛭䛾ᙳ㡪ㄪᰝ䛷䛿䛺䛟䛭䜜䛜ጇᙜ䛛䜢⪃䛘䜛䛣䛸䛻᫬㛫䜢౑䛔䛯䛔 ż ◚ቯⓗኚ᭦䛜㉳䛣䛳䛶䜒ᙳ㡪⠊ᅖ䜢ᑠ䛥䛟ಖ䛴 Ŷ

    ᑐᛂ䛩䜛䜎䛷䛾⊰ண䛜䛷䛝䜛 ż ⮬ศ䛯䛱䛾䛯䜑䛾6GTTCHQTO/QFWNG䛺䛾䛷㐣ᗘ䛺஫᥮ᛶ䜢ព㆑䛧䛺䛟䛶῭䜐 Ɣ 䜟䛛䜚䜔䛩䛥䛸䛧䛶5GOCPVKE8GTUKQPKPI䛸䛧䛶䛔䜛䛜ཝᐦ䛷䛿䛺䛔 ż 䛜䜣䜀䜙䛺䛔
  7. 6GTTCHQTO/QFWNG౛ Ɣ 0WJdYX42A ż 䝅䝇䝔䝮䛻䜘䛳䛶ᚲせ䛺ᩘ䛜␗䛺䜛䛾䛷 42A༢య䛻䛧䛶䛔䜛˟42BBN\`SLN䛸୍⥴䛻䛧 䛺䛔ˠ Ɣ 0WJdYX42B2V_]^N\ ż

    2V_]^N\˲BN\`SLN͌˲䛻䛸䛿㝈䜙䛺䛔䛾䛷42B2V_]^N\༢య䛻䛧䛶䛔䜛 ż ௒䛾タィ䛜䛭䛖䛺䛳䛶䛔䜛䛰䛡
  8. 6GTTCHQTO/QFWNG໬䛾䝯䝸䝑䝖 Ɣ 䝸䝸䞊䝇䜎䛷䛜㏿䛔 ż <YM_VN䛜䛒䜜䜀䛩䛠䛻స䜜䜛 Ŷ 䛩䛷䛻౑䜟䜜䛶䛔䜛䜒䛾䛷䛒䜜䜀 ˳᳨ド䝁䝇䝖䜒ῶ䜛 ż 䝏䞊䝮䛾䝘䝺䝑䝆䛜㞟⣙䛥䜜䛶䛔䜛䛾䛷㏞䛔䛻䛟䛔

    Ŷ ㏞䛖䜉䛝䛸䛝䜒䛒䜛 ż ή䛹䛖タᐃ䛧䛯䜙䝅䝇䝔䝮䛜ື䛟䛛䛷䛿䛺䛟 ˳ 䛹䛖䛧䛯䜙䜘䜚䜘䛟䝅䝇䝔䝮䜢ື䛛䛫䜛䛛䛻䝣䜷䞊䜹䝇䛷䛝䛯 Ɣ 䝅䝇䝔䝮䛜ቑ䛘䛶䜒ᢕᥱ䜔⟶⌮䛜䛭䛣䜎䛷኱ኚ䛷䛿䛺䛔 ż 䛒䛒䚸䛒䛾䝰䝆䝳䞊䝹౑䛳䛶䜛䛾䛽䚸 $RRTQXG䟿 ż 䝞䞊䝆䝵䞁䜢ୖ䛢䛶6GTTCHQTO$RRN[䛩䜜䜀㐺ᛂ䛥䜜䛶䛔䜛ୡ⏺ほ䜢┠ᣦ䛩
  9. 6GTTCHQTO/QFWNG໬䛾䝯䝸䝑䝖 Ɣ 」㞧䛺䜒䛾䜢㓄ᕸ䛧䜔䛩䛔 Ɣ GI/CEMGTGN䛷䛿䝁䞁䝔䝘໬䜢㐍䜑䛶䛔䜛 ż (&䛸(&5䛷୪⾜✌ື䛥䛫䛯䛔 9GKIJVGF4QWVKPI䛧䛯䛔 ż (&5䛷䛿&QFG'GRNQ[䜢౑䛳䛶%NWG*TGGP'GRNQ[OGPV䛧䛯䛔

    ż &QFG'GRNQ[䛾ไ⣙䛸䛧䛶%NWG*TGGP'GRNQ[OGPV䛩䜛$.%.KUVGPGT䛻䛿 %NWG*TGGP'GRNQ[OGPV௨እ䛾6CTIGV*TQWR䜢CVVCEJ䛷䛝䛺䛔 ż ĺ䛭䛾䜎䜎䛷䛿ᐇ⌧䛷䛝䛺䛔䜒䛾䛜䛒䜛
  10. 」㞧䛺䜒䛾䜢㓄ᕸ䛩䜛 Ɣ ᐇ⌧䛷䛝䜛䛛䛯䛱䛷䝰䝆䝳䞊䝹䛻䛩䜛 ż 䠍䛴䛾$.%䛷9GKIJVGF4QWVKPI䛧䛺䛜䜙%NWG*TGGP'GRNQ[OGPV䛧䛯䛔ሙྜ Ŷ ゎỴ䛾䛯䜑䛾.CODFC䜢䝰䝆䝳䞊䝹䛸䛧䛶⏝ព Ɣ &QFG'GRNQ[䝰䝆䝳䞊䝹 Ɣ

    $95.CODFC䝰䝆䝳䞊䝹 ż ู䝰䝆䝳䞊䝹䛸䛧䛯 Ŷ 䛭䛾.CODFC䜢ᚲせ䛸䛧䛺䛔ሙྜ䜒䛒䜛䛾䛷⤌䜏ྜ䜟䛫䜙䜜䜛䜒䛾䛸䛧䛯 Ŷ ᧔ཤ䛧䜔䛩䛟 Ɣ ⛣⾜䛜⤊䜟䜛䛸ᚲせ䛺䛟䛺䜛䜒䛾䛷䛒䜛 Ŷ 」㞧䛰䛡䛹⧞䜚㏉䛧䛯䛔䜒䛾䛻䜒ྥ䛔䛶䛔䜛
  11. 䜎䛰㊊䜚䛶䛺䛔 Ɣ 6GTTCHQTO䛿ᵓᡂ⟶⌮䝒䞊䝹 ż 䝕䝥䝻䜲䝒䞊䝹䛷䛿䛺䛔 ż ᐉゝⓗ䛺䜒䛾ᢅ䛖䛻䛿䛣䜜䛷䛔䛔䛾䛛䠛䛸䛔䛖ㄢ㢟䛜䛒䜛 Ɣ MWDGTPGVGU䝸䝧䞁䝆䛻ྥ䛡䛶 ż

    &NQWF0CVKXG䛺䝰䝙䝍䝸䞁䜾䝃䞊䝡䝇䜢ᥦ౪䛩䜛䛯䜑䛻䜔䛳䛶䛔䛟 ż 䛣䛣䛻6GTTCHQTO䛜䛿䜎䜛䛾䛛䠛䛿⪃䛘䛶䛔䛟ᚲせ䛜䛒䜛 Ɣ &Ͳ䛧䛶䛔䛝䛯䛔 ż 䛣䜜䛛䜙䛰䛽
  12. 䝯䞁䝔䝘䞁䝇䛜ᛀ䜜䜙䜜䛜䛱䛺䜒䛾䜢䝁䞊䝗໬ Ɣ 䝰䝙䝍䝸䞁䜾䝎䝑䝅䝳䝪䞊䝗䛳䛶⨨䛝ཤ䜚䛻䛥䜜䛜䛱 ż ௒ᚲせ䛺䛾䛻䟿䛸䛔䛖᫬䛻ྂ䜃䛶䛔䛯䜚 ż 䝃䝤䝅䝇䝔䝮䛜ቑ䛘䛯䛡䛹㏣ᚑ䛷䛝䛶䛔䛺䛛䛳䛯䜚 ż ኚ᭦ᒚṔ䜢㏣䛔䛻䛟䛛䛳䛯䜚 ż

    䝃䞊䝡䝇䛾䝸䝥䝺䜲䝇䛜䛱䜗䛳䛸኱ኚ Ŷ $.%ධ䜜᭰䛘䛯䛾䛷䝎䝑䝅䝳䝪䞊䝗䛾᭦᪂䜢䛧䛯䛔䛡䛹 $.%䛾䜾䝷䝣䛔䛳䜁䛔 䛒䛳䛶䛣䜜䜢඲㒊ධ䜜᭰䛘䜛䛾኱ኚ 
  13. 䝯䞁䝔䝘䞁䝇䛜ᛀ䜜䜙䜜䛜䛱䛺䜒䛾䜢䝁䞊䝗໬ Ɣ $OC\QP&NQWF9CVEJ䛾'CUJDQCTF䜒6GTTCHQTO໬ ż ⤖ᵓ኱ኚ Ŷ 'CUJDQTCF䛾DQF[䛾䜘䛖䛻኱䛝䛺䜒䛾䛿Ᏻ┤䛻䜔䜛䛸ཝ䛧䛔䛛䜒 Ŷ 䛒䜛⛬ᗘศ๭䛩䜛䛺䛹 ż

    VGTTCHQTOKORQTV䛸CRRN[䜢⧞䜚㏉䛩 Ɣ ⎔ቃ䛻䠍䛴䛺䛾䛷6GTTCHQTO/QFWNG䛻䛿䛧䛶䛔䛺䛔 ż 䝔䞁䝥䝺䞊䝖໬䛧䛶䝅䝇䝔䝮䛤䛸䛻䝎䝑䝅䝳䝪䞊䝗䜢⏝ព䛧䛯䛔䛺䜙䝰䝆䝳䞊䝹໬䛿䜰䝸