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

after of Infrastructure-as-Code-is-very-tired

after of Infrastructure-as-Code-is-very-tired

shogomuranushi

July 31, 2019
Tweet

More Decks by shogomuranushi

Other Decks in Programming

Transcript

  1. • σΟϨΫτϦઃܭ • Environment Λ෼͚Δ • tfstate ͸ s3 backend

    ʹ • Workspace ͷ׆༻ • Map ؔ਺ϑϧ׆༻ ৄղʂTerraform Best Practices in 2017
  2. • 1೥ͿΓʹTerraformΛௐ΂Δ • forจ͸Ͱ͖ͳ͍ʁʂͯ͜ͱ͸ɾɾ • Μʁ0.12Ͱ͸forจ͕࢖͑Δͱͳ • 0.12ΛϏϧυ͢Δ͔ʁ͍΍ɺ·ͱ΋ʹಈ͔ͳ͍ͷ΋໘౗ͩͳ • ΜʁTerraform

    Module Registryͱ͍͏΋ͷ͕͋ΔͧɻGithubʹ ίʔυ্͕͕ͬͯΔ • moduleͷࢀߟʹͤͯ͞΋Β͓͏ ΋ͬͱΩϨΠʹॻ͚ͳ͍΋ͷ͔
  3. • ʮͦ͏͍͑͹ɺRedshiftͷ࣌΋ࢥͬͨʯ • ʮSampleࢼͯ͠ɺmoduleԽͯ͠ɺΩϨΠͳίʔυʹͯ͠…ʯ • ʮͰɺRedshiftͷσϓϩΠ͕Ұճ20-30෼͔͔Δ͔ΒɺԿճ͔΍Γ ௚ͯ͠…ʯ • ʮͦΕԿ͔͔࣌ؒΔͶΜɻϘλϯϙνϙνͰ਺෼Ͱग़དྷΔ΍Μʯ •

    ʮdevɺstgɺprod࡞ͬͯ΋࡞ۀ࣌ؒ͸10෼ఔ౓΍Μʯ • ʮࠩ෼ؾʹ͠ͳ͕ΒɺίʔυͷϦϑΝΫλߟ͑ͳ͕Β࢖͏ϝϦο τ͋Δʁʯ ͦͷ࣌ͷ৺ͷ੠ू ͦͷ̎ ʮ͍΍ɺແཧʯ
  4. • ίʔυԽ͢Δ • ALB + EC2 + RDBͷηοτ͸όϯόϯ࡞ΔΜͩΑͶʔʢίετޮ཰ྑ͍ʣ • DR༻ʹ͙͢ʹ্ཱͪ͛Δඞཁ͕͋Δʢεϐʔυ͋Δʣ

    • ଟϦʔδϣϯʹαʔϏεల։͢Δ໺๬͕͋Δʢεϐʔυ͋Δʣ • ϦιʔεؒΛܨ͍Ͱ͍Δܥʢίετޮ཰ߴ͍ʣ • ΦϖϛεΛՄೳͳݶΓഉআ͍ͨ͠ʢࣗಈԽʹΑΔϦεΫϔοδ͸Մೳʣ • ͕͔ͩ͠͠ ίετɺεϐʔυɺϦεΫͷධՁྫ
  5. ݸਓͷ੒௕͕ձࣾͷ੒௕ • ྫ͑͹ɺτϨϯυͷٕज़ͷ༻్ΛݟۃΊͯదࡐదॴͰ৭ʑͳαʔϏεɾπʔϧΛ૊ Έ߹ΘͤΕ͹ແବ͕ݮΓࣄۀ੒௕͕Ճ଎͢Δ • AWSΛֶͿ͜ͱͰʮނোͷͨΊͷઃܭʢdesign for faillerʣʯΛֶ΂Δ • KubernetesΛֶͿ͜ͱͰʮએݴతΞʔΩςΫνϟ͸͜͏͍͏͜ͱ͔ʯͱ͍͏ઃ

    ܭΛֶ΂ΔɺͳͲ • ͦΕͳΒ͹ɺࣄۀΛ੒௕ͤ͞Δ্Ͱ৽͍ٕ͠ज़΍֓೦ͷशಘʢ౤ࢿʣ͸ඞਢ • ୭͔͚ͩ৽͍͜͠ͱΛֶͿͷ͸ଞ͕෇͍ͯ͜ͳ͍͔΋͠Εͳ͍ͷͰɺνʔϜ಺Ͱͦ ΕͧΕٕज़Λֶͼ߹͍ɺ͓ޓ͍Ͱڞ༗͋͠͏ͷ΋͋Γ
  6. AWS CDK • ͨͿΜ୭͔͕঺հͯ͘͠ΕΔͱࢥ͏ͷͰɺҰൠతͳ͜ͱ͸ॻ͔ͳ͍ • No YAML, Yes Programing Language.

    • গͳ͍ίʔυྔͰଟ͘ͷ͜ͱ͕࣮ݱͰ͖Δ • Ͱ΋ɺCFnͳͷͰద༻࣌ͷڍಈͷཧղ͸ඞཁɻ࡞Δ͚ͩͷ෼͸ָ • ͨͿΜҰੈΛ෩ᴆ͢ΔΜ͡Όͳ͍͔ͳ • ࣾ಺Ͱ͸SDKͰ΋ྑ͍Μ͡ΌͶʁͱ͍͏੠͕
 ʢಈ͖෼͔Δͱ͍͏ҙຯͰʣ
  7. Terraform v0.12 • for, for_eachจ͕ॻ͚ΔΑ͏ʹͳͬͨ • NullΛׂΓ౰ͯՄೳʹʢʹఆٛͯ͠ͳ͍͜ͱͱಉ͡ʣ • Split΋ѻ͍΍͘͢ •

    ͦͷଞ৭ʑ • ͑ɺɺ͜͜·ͰདྷͨΒϓϩάϥϛϯάݴޠͰॻ͘CDKͷํ͕…? • ͋·ΓτϦοΩʔͳػೳΛ࢖͍͗͢Δͱ୭΋෇͍ͯ͜Εͳ͍ͷͰ
 ༻๏༻ྔ͸஫ҙ͠·͠ΐ͏
  8. ݸਓతײ૝ • ਺೥ޙʹ͸ ൚༻ݴޠ vs DSL ໰୊͕ຄൃ͢Δ • Ͱ΋ɺঃʑʹऩଋָͯ͠ʹͳΔ͸ͣͳͷͰWelcome •

    CDKͩͱॻ͘͜ͱ͸ָʹͳΔ • ͚Ͳɺӡ༻ɾҡ࣋͢Δ͜ͱ͸ผɻCFnΛϥοϓ͍ͯ͠Δ͚ͩͳ ͷͰίʔυͷద༻࣌ͷڍಈ͸มΘΒͣཧղ͕ඞཁ
  9. ·͞ʹ޲͍͍ͯΔɻ͙͢ʹͰ΋΍ͬͨํ͕͍͍΍ͭ • ඵͰ൓ө͞ΕΔ • ফͯ͠΋ɺ͙͢ʹద༻͢Ε͹໰୊ͳ͍ • Կճ΋࡞Δ • ྫ •

    Datadog: Monitor • AWS: CloudTrail, SNS, SQS, Route53, etc… • ͜ͷล͔Β࢝ΊΔͱɺॻ͖ํ΍࢖͍উख͕෼͔Δ
  10. ·͞ʹ޲͍͍ͯͳ͍ • ࡞੒ʹ͕͔͔࣌ؒΔ΍ͭʢDBܥʣ • Կճ΋࡞Βͳ͍΍ͭʢRedShift΍CloudFrontʣ • ফ͢ͱϚζΠ΍ͭ • Α͘มߋ͢Δ΍ͭ •

    ͜ͷล͔Β࢝ΊΔͱɺ1ճ1ճͷ࡞ۀ͕ා͍ɻࠩ෼͕ग़ͨͱ͖ʹຖ ճٵऩ͢Δͷ͕ਏ͍ɻ͔͔࣌ؒΔͷͰςετ͔ͳΓ͠ΜͲ͍