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

AWS CDKでまるっと インフラ環境をIaCしたぞ!

kubotak
September 24, 2022

AWS CDKでまるっと インフラ環境をIaCしたぞ!

PHPConference2022 ゴールドスポンサーLT 2022/09/24

kubotak

September 24, 2022
Tweet

More Decks by kubotak

Other Decks in Programming

Transcript

  1. Copyright© M&AΫϥ΢υ ٻਓ޿ࠂαΠτͷΑ͏ͳM&AμΠϨΫτϚονϯά 3 ങ͍ख ɾҊ݅ใु͸M&A੒ޭใुͷΈ ɾ࠷௿ख਺ྉͳ͠ ɾചΓखιʔγϯάͷνϟωϧ͕૿͑Δ ɾM&AχʔζΛൃ৴͢Δ͚ͩͰചΓखΛू٬ ɾ஥հۀऀΛհͣ͞ʹμΠϨΫτʹ΍ΓऔΓՄೳ

    ɾજࡏ૚ʹ΋Ϧʔν͕Մೳ ख਺ྉແ ྉ ※ϓϥοτϑΥʔϜҊ݅ͷ৔߹ ※ ചΓख 1.ܝࡌ͢Δ ɾങ͍खͷM&AχʔζΛࣗΒௐ΂Δ͜ͱ͕Մೳ
 ɾ஥հۀऀΛհͣ͞ʹμΠϨΫτʹ΍ΓऔΓՄೳ
 ɾങ͍खͷM&A୲౰ऀʹ௚઀ίϯλΫτΛͱΕΔ
 ɾ஥հۀऀΛ࢖Θͳ͍ͷͰख਺ྉ͕ແྉ 2.ΦϑΝʔ͢Δ M&Aɾग़ࢿχʔζΛܝࡌ ങ͍खͷϝϦοτ ചΓखͷϝϦοτ ɾ஥հۀऀΛ࢖Θͳ͍ͷͰख਺ྉ͕ແྉ ʓʓྖҬͷձࣾΛ ืू͠·͢ ͜ͷձࣾͱҰॹʹ ΍͍͖͍ͬͯͨʂ 3 PR
  2. Copyright© M&AΫϥ΢υ AWS CDKͱ͸ AWS Cloud Development Kit (AWS CDK)

    AWS CloudFormationΛ࣮ߦ͢ΔίʔυΛએݴతͳςϯϓϨʔτͱͯ͠ఆٛ͢Δ͜ͱͰϓϩϏ δϣχϯάΛ࣮ݱͰ͖ΔϑϨʔϜϫʔΫ CloudFormationʹΑΓIaC͕࣮ߦ͞ΕΔͷͰࣗಈϩʔϧόοΫ΍υϦϑτݕग़ʢखಈมߋͯ͠͠ ·ͬͨ৔߹ʹఆٛͱ࣮ମ͕ဃ཭͢Δ͜ͱΛݕग़ʣ͕Ͱ͖Δɻ ҎԼͷݴޠ͕αϙʔτ͞Ε͍ͯΔ PHP͸ͳ͍
  3. Copyright© M&AΫϥ΢υ AWS CDKͱ͸ AWS CDK Constructs CDK͸APPɺStackɺConstructͷ֤ཁૉʹΑͬͯߏ੒͞Ε͍ͯΔɻ • APP

    ◦ Stackͷґଘؔ܎ͷఆٛ • Stack ◦ CloudformationͷStack୯Ґ ◦ σϓϩΠͷ࠷খ୯Ґ • Construct ◦ AWSͷϦιʔε
  4. Copyright© M&AΫϥ΢υ AWS CDKͱ͸ Construct Library CDK͸Construct LibraryΛ࢖༻ͯ͠AWSϦιʔεΛఆٛ͠·͢ɻ Construct Libraryʹ͸ҎԼͷ3छྨʹ෼͚ΒΕ·͢ɻ

    • low-level constructsʢL1ʣ ◦ ௚ײతʹϦιʔεΛఆٛ͢Δ͜ͱ͕Ͱ͖ɺσϑΥϧτ஋͕ઃఆࡁΈͷศརͳϝιου ͕ఏڙ͞ΕΔ • higher-level, intent-based APIʢL2ʣ ◦ ϓϩύςΟΛ໌ࣔతʹઃఆ͢Δඞཁ͕͋ΔͨΊɺύϥϝʔλΛৄࡉʹઃఆͰ͖Δ ◦ Ϋϥε໊ʹCfnϓϨϑΟοΫε͕͍͍ͭͯΔ • patternsʢL3ʣ ◦ ҰൠతͳΞʔΩςΫνϟύλʔϯʹै͏ߴϨϕϧͷConstructΛఏڙ
  5. Copyright© M&AΫϥ΢υ M&AΫϥ΢υͷࣄྫ M&AΫϥ΢υͷΠϯϑϥ Amazon Web Service(AWS)্Ͱߏங͍ͯ͠·͢ɻ ओʹҎԼͷαʔϏεΛར༻ • ECS(Fargate)

    • ECR • Lambda • Cloudfront • Open Search Service • ALB • CloudWatch • Athena • S3 • RDS • ElastiCache • SQS • etc
  6. Copyright© M&AΫϥ΢υ AWS CDKΛར༻ͯ͠ݟ͑ͨ՝୊ • CloudFromation͕࣮ߦ͞ΕΔͨΊɺ׬ྃ·Ͱ݁ߏ͕͔͔࣌ؒΔɻ ◦ ಛʹCloudfront͸֤Edgeαʔόʔͷ൓ө·Ͱ଴͍ͬͯΔײ͡ʁͰ஗͍ • Fargate

    SpotΛ࢖͏ͨΊʹ͸L1 ConstructͰ͸͏·͘ߦ͔ͳ͔ͬͨͷͰL2ʹΑΔCfnΫϥ εΛ࢖͏ඞཁ͕͋ͬͨɻͦͷଞʹ΋݁ہCfnΫϥεͰॻ͔ͳ͍ͱࢦఆͰ͖ͳ͍΋ͷ͕ଟ͔ͬ ͨ • ϥΠϒϥϦ͕TypeScriptͷݴޠͷྑ͞Λ࢖͍੾Ε͍ͯͳ͍ ◦ ܾ·ͬͨจࣈ͔͠࢖͑ͳ͍ͳΒUnionͰఆٛͯ͠΄͍͠ɻStringʹͳ͍ͬͯΔͷͰɺ ͳʹ͕ࢦఆͰ͖Δ͔Θ͔Βͳ͍΋ͷ͕݁ߏ͋Δʢ݁ہެࣜυΩϡϝϯτΛݟͳ͚Ε͹ ࢖͑ͳ͍ʣ • CDKͷίʔυ΋ͨͩཏྻ͢Δ͚ͩͰ͸ͳ͘Stack΍Construct୯ҐΛ͏·͘ઃܭ͢Δඞཁ͕ ͋Δͱײͨ͡