Copilotによるお手軽3分ECSクッキング / The Cooking of AWS Copilot

C636093440dd4a8be6416e83cb980979?s=47 iselegant
September 13, 2020

Copilotによるお手軽3分ECSクッキング / The Cooking of AWS Copilot

2020-09-13 JAWS SONICでオンライン登壇させていただいたAWS Copilotの登壇資料です。

C636093440dd4a8be6416e83cb980979?s=128

iselegant

September 13, 2020
Tweet

Transcript

  1. C o p i l o t ʹΑΔ ͓खܰ3෼ ECSΫοΩϯά

  2. ৽Ҫ խ໵ ᖛా ޹࣏ .BTBZB"SBJ ,PKJ)BNBEB ϑϧελοΫσΟϕϩούʔ ."%νʔϜϚωʔδϟʔ "1/"845PQ&OHJOFFST +BQBO"1/"NCBTTBEPS

    本⽇のウェイター 本⽇のシェフ $PQJMPUͷઆ໌୲౰ $PQJMPUͷσϞ୲౰ !NTZ !IBNBLP
  3. ࠓ೔ͷϝΠϯσΟογϡ͸ $PQJMPUͰ͢ɻ ࣄલʹϋϚίʔγΣϑʹΑΔ ؆୯ͳԼ͝͠Β͑ͷ༷ࢠΛݟͯΈ·͠ΐ͏ɻ σϞ

  4. վΊͯɺࠓ೔ͷϝΠϯσΟογϡ͸ $PQJMPUͰ͢ɻ

  5. AWSϚωʔδυͳίϯςφαʔϏεͱ͍͑͹ɺ

  6. AWSϚωʔδυͳίϯςφαʔϏεͱ͍͑͹ɺ

  7. AWSϚωʔδυͳίϯςφαʔϏεͱ͍͑͹ɺ Amazon ECS AWS Fargate (コントロールプレーン) (データプレーン)

  8. ͦΕͳΓͷ࢓ࠐΈ࡞ۀ ECS & Fargate Λ৯ͨ͢Ίʹ͸ɺ ͕ඞཁͱͳΓ·͢ɻ

  9. ͦΕͳΓͷ࢓ࠐΈ࡞ۀ ECS & Fargate Λ৯ͨ͢Ίʹ͸ɺ ͕ඞཁͱͳΓ·͢ɻ ʮ࢓ࠐΈʯͱ͸Ͳ͏͍͏ҙຯʁ

  10. ࢓ࠐΈ࡞ۀͷશ༰Λ ݟ͍͖ͯ·͢ɻ

  11. ҎԼΛલఏͱ͠·͢ɻ ίϯςφΞϓϦ͕४උࡁΈ "84ΞΧ΢ϯτௐୡࡁΈ σϓϩΠ͢Δͷ͸ 8FCΞϓϦ

  12. 71$ͷ࡞੒ 4UFQ

  13. TVCOFUͷ࡞੒ 4UFQ Ϛϧν ";ߏ੒Λ૊Ήલఏͱͯ͠ɺ 1VCMJDTVCOFUͱ 1SJWBUFTVCOFUΛ ͦΕͧΕͭͣͭ࡞੒ɻ

  14. Πϯλʔωοτ(8ͱ ϧʔτςʔϒϧͷ࡞੒ 4UFQ 1VCMJD4VCOFUͷσϑΥϧτϧʔτΛ Πϯλʔωοτ(8ʹ޲͘Α͏ʹ͢Δɻ

  15. "-#ͷ࡞੒ 4UFQ -#ɺϦεφʔɺλʔήοτάϧʔϓ࡞੒ɻ λʔήοτάϧʔϓͷͿΒԼ͛ઌͳ͠ɻ "-#༻ηΩϡϦςΟάϧʔϓΛ࡞੒ɻ

  16. &$3ͷ࡞੒ 4UFQ ࡞੒ͨ͠ίϯςφΞϓϦΛ &$3ʹϓογϡɻ

  17. $MPVE8BUDI -PH(SPVQͷ࡞੒ 4UFQ ίϯςφͷϩάग़ྗઌͱͯ͠༻ҙɻ

  18. &$4Ϧιʔε࡞੒ 4UFQ ϋϚΓͲ͜Ζ͕Ұ൪ଟ͍࡞ۀɻ ؔ࿈ *".ϩʔϧɺ&$4Ϋϥελʔɺ &$4λεΫఆٛɺ&$4αʔϏεΛ࡞੒ɻ

  19. ΞϓϦσϓϩΠ 4UFQ 'BSHBUF্ʹల։͞Εͨ ίϯςφ8FCΞϓϦͷಈ࡞֬ೝΛߦ͏ɻ

  20. 71$ͷ ࡞੒ 4VCOFUͷ ࡞੒ *(8ͱϧʔτ ςʔϒϧ࡞੒ "-#ͷ ࡞੒ &$3ͷ ࡞੒

    $8-PHTͷ ࡞੒ &$4ͷ ࡞੒ ΞϓϦ σϓϩΠ Step.1 Step.2 Step.3 Step.4 Step.5 Step.6 Step.7 Step.8 ࢓ࠐΈͷߦఔΛ͓͞Β͍ͯ͠Έ·͢ɻ
  21. 71$ͷ ࡞੒ 4VCOFUͷ ࡞੒ *(8ͱϧʔτ ςʔϒϧ࡞੒ "-#ͷ ࡞੒ &$3ͷ ࡞੒

    $8-PHTͷ ࡞੒ &$4ͷ ࡞੒ ΞϓϦ σϓϩΠ Step.1 Step.2 Step.3 Step.4 Step.5 Step.6 Step.7 Step.8 શߦఔΛ͓͞Β͍ͯ͠Έ·͢ɻ ख਺͕ଟ͘ɺॳΊͯར༻͢Δ৔߹ɺ ϋʔυϧ͕ߴ͍ͱײ͡·ͤΜ͔ʁ
  22. ૣ͘ΞϓϦΛσϓϩΠ͍ͨ͠ ࢓ࠐΈΛͬ͢ඈ͹ͯ͠ ECS & Fargate ্ʹ ͱ͍͏χʔζ΋͋Δ͸ͣɻ

  23. ૣ͘ΞϓϦΛσϓϩΠ͍ͨ͠ ࢓ࠐΈΛͬ͢ඈ͹ͯ͠ ECS & Fargate ্ʹ ͱ͍͏χʔζ΋͋Δ͸ͣɻ ECS&FargateΛ ࢖͏ͷͰɺ ײ৮Λ௫Έ͍ͨɻ

    ؆୯ͳ"1*Λ ͬ͞͞ͱ ఏڙ͍ͨ͠ɻ ΞϓϦ։ൃʹ ஫ྗ͍ͨ͠ɻ ΞϓϦσϓϩΠ Մೳͳຊ൪؀ڥΛ αοͱ೺Ѳ͍ͨ͠ɻ
  24. Ͳ͏͢Ε͹͍͍ʁ

  25. AWS Copilot ・ECS & Fargate 構築とアプリ自動デプロイが可能なツール ɾͭ޻ఔͰϓϩμΫγϣϯϨσΟͳ؀ڥ͕४උ ɾγϯϓϧͳ CI/CD ύΠϓϥΠϯ΋༻ҙՄೳ

    ݱࡏ͸ v0.3.0
  26. AWS Copilot ・ECS & Fargate 構築とアプリ自動デプロイが可能なツール ɾͭ޻ఔͰϓϩμΫγϣϯϨσΟͳ؀ڥ͕४උ ɾγϯϓϧͳ CI/CD ύΠϓϥΠϯ΋༻ҙՄೳ

    ݱࡏ͸ v0.3.0
  27. Application Service Environment $PQJMPUͭͷϝΠϯίϯηϓτ

  28. Application (app) &OWJSPONFOUͱ 4FSWJDFͷ·ͱ·Γ ・Copilot で作成される AWS リソース全てを表現 ɾService ͱ

    Environment ͸࣍εϥΠυʹͯ ɾਖ਼֬ʹ͸ɺpipeline ΋ؚ·ΕΔ
  29. Environment (env) ΞϓϦ։ൃͰ෼཭͢΂͖؀ڥͷఆٛ ɾʮ։ൃʯʮςετʯʮຊ൪ʯͳͲݸผͷ؀ڥΛఆٛͰ͖Δ ɾService のベースとなる要素 ɾVPC Λத৺ͱͨ͠ΞϓϦڞ௨ͳ AWS ϦιʔεΛ࢘Δ

  30. Environment VPC ؔ࿈Ϧιʔε΍ECS Cluster ͸ Environmentͷ؅׋ɻ ˞pipeline ༻ͷ S3 Bucket

    ΋ର৅ɻ
  31. Environment ෳ਺ͷ&OWJSPONFOUΛ࡞੒΋Ͱ͖Δɻ ˞։ൃ؀ڥͱຊ൪؀ڥͷ෼཭༻్ɺͳͲ

  32. Application Environment Application Environment

  33. Application Environment Application Environment Environment Environment

  34. 検証App PoC ؀ڥ 実App ։ൃ؀ڥ εςʔδϯά؀ڥ ຊ൪؀ڥ

  35. Service (svc) ΞϓϦέʔγϣϯຖͷϦιʔεఆٛ ɾEnvironment ͸ΞϓϦέʔγϣϯͰڞ௨ɺService ͸ݸผɻ ɾΞϓϦͷ਽ܗͱͯ͠ɺҎԼͷ͔ͭΒબ୒Ͱ͖Δɻ Load Balanced Web

    Service Backend Service
  36. Service ΞϓϦ୯ҐͰ͋ΔECS Service ΍ ECS Task ఆٛɺECR ͳͲ͕ Service ͷ؅׋ɻ

    ˞ࠨਤ͸ Load Balanced Web Service Λ બ୒ͨ͠৔߹ͷྫɻ
  37. Service ෳ਺ͷ Environment ʹ ಉҰͷ Service ΛσϓϩΠ͢Δ͜ͱ΋Մೳɻ

  38. Application Environment Service Application Service Service Environment Environment Environment

  39. Application Environment Service Application Service Service Environment Environment Environment

  40. 検証App PoC ؀ڥ サンプルAPI 実App όοΫΤϯυ"1* 8FC"1* ։ൃ؀ڥ εςʔδϯά؀ڥ ຊ൪؀ڥ

  41. Application Service Environment $PQJMPUͭͷϝΠϯίϯηϓτ ͍ͬͨΜ·ͱΊ = + Environment Environment Service

    Service
  42. AWS Copilot ・ECS & Fargate 構築とアプリ自動デプロイが可能なツール ɾͭ޻ఔͰϓϩμΫγϣϯϨσΟͳ؀ڥ͕४උ ɾγϯϓϧͳ CI/CD ύΠϓϥΠϯ΋༻ҙՄೳ

  43. > app ├ Dockerfile └ src ├ hoge.js :

  44. > Terminal AWS Environment app ├ Dockerfile └ src ├

    hoge.js : Work Folder
  45. > copilot init Copilot 初期化 app ├ Dockerfile └ src

    ├ hoge.js :
  46. > copilot init What would you like to name your

    application? [? for help] ͭΊͷ޻ఔ ΞϓϦ໊ͷೖྗ app ├ Dockerfile └ src ├ hoge.js :
  47. > copilot init Application name: copilot-app Which service type best

    represents your service's architecture? [Use arrows to move, type to filter, ? for more help] > Load Balanced Web Service Backend Service ͭΊͷ޻ఔ ΞʔΩςΫνϟͷλΠϓΛબ୒ app ├ Dockerfile └ src ├ hoge.js :
  48. > copilot init Application name: copilot-app Service type: Load Balanced

    Web Service What do you want to name this Load Balanced Web Service? [? for help] ͭΊͷ޻ఔ બ୒ͨ͠αʔϏεͷ໊લΛೖྗ app ├ Dockerfile └ src ├ hoge.js :
  49. > copilot init Application name: copilot-app Service type: Load Balanced

    Web Service Service name: front-end Which Dockerfile would you like to use for front-end? [Use arrows to move, type to filter, ? for more help] > ./Dockerfile ͭΊͷ޻ఔ σϓϩΠ͢Δ%PDLFSGJMFΛબ୒ app ├ Dockerfile └ src ├ hoge.js :
  50. > copilot init Application name: copilot-app Service type: Load Balanced

    Web Service Service name: front-end Dockerfile: ./Dockerfile Ok great, we'll set up ... app ├ Dockerfile └ src ├ hoge.js :
  51. > copilot init Application name: copilot-app Service type: Load Balanced

    Web Service Service name: front-end Dockerfile: ./Dockerfile Ok great, we'll set up ... 4FSWJDFຖͷϚχϑΣετ͕ࣗಈͰ࡞੒ ˞λεΫ਺ɺ$16ɺϝϞϦɺ"-#ͷϙʔτ൪߸ͳͲ͕ࢦఆՄೳ ࣮ߦ༻ͷϩʔϧ͕࡞੒ app ├ copilot │ └ front-end │ └ manifest.yml ├ Dockerfile └ src ├ hoge.js : Cloud Formation Stack
  52. > copilot init Application name: copilot-app Service type: Load Balanced

    Web Service Service name: front-end Dockerfile: ./Dockerfile Ok great, we'll set up ... Would you like to deploy a test environment? [? for help] (y/N) app ├ copilot │ └ front-end │ └ manifest.yml ├ Dockerfile └ src ├ hoge.js : ͭΊͷ޻ఔ ςετ؀ڥʹΞϓϦΛσϓϩΠ͢Δ͔Ͳ͏͔ɻ Cloud Formation Stack
  53. > copilot init Application name: copilot-app Service type: Load Balanced

    Web Service Service name: front-end Dockerfile: ./Dockerfile Ok great, we'll set up ... Deploy: Yes ⠙ Creating the infrastructure ... app ├ copilot │ └ front-end │ └ manifest.yml ├ Dockerfile └ src ├ hoge.js : Cloud Formation Stack
  54. Cloud Formation app ├ copilot │ └ front-end │ └

    manifest.yml ├ Dockerfile └ src ├ hoge.js : Environment ʹ֘౰͢Δ CFn Stack ͕࡞੒ ల։ > copilot init Application name: copilot-app Service type: Load Balanced Web Service Service name: front-end Dockerfile: ./Dockerfile Ok great, we'll set up ... Deploy: Yes ⠙ Creating the infrastructure ... Stack Stack (env)
  55. Cloud Formation app ├ copilot │ └ front-end │ └

    manifest.yml ├ Dockerfile └ src ├ hoge.js : &$3ͱ QJQFMJOF༻ 4༻ͷ CFn Stack ͕࡞੒ ల։ > copilot init Application name: copilot-app Service type: Load Balanced Web Service Service name: front-end Dockerfile: ./Dockerfile Ok great, we'll set up ... Deploy: Yes ⠙ Creating the infrastructure ... Stack Stack (env) Stack (app)
  56. Cloud Formation app ├ copilot │ └ front-end │ └

    manifest.yml ├ Dockerfile └ src ├ hoge.js : %PDLFSΠϝʔδ͕ Ϗϧυ͞Εͯ &$3ʹ QVTI > copilot init Application name: copilot-app Service type: Load Balanced Web Service Service name: front-end Dockerfile: ./Dockerfile Ok great, we'll set up ... Deploy: Yes ⠙ Creating the infrastructure ... Stack Stack (env) Stack (app)
  57. Cloud Formation Stack app ├ copilot │ └ front-end │

    └ manifest.yml ├ Dockerfile └ src ├ hoge.js : > copilot init Application name: copilot-app Service type: Load Balanced Web Service Service name: front-end Dockerfile: ./Dockerfile Ok great, we'll set up ... Deploy: Yes ⠙ Creating the infrastructure ... ✓Deployed front-end, you can access it at http://xxxxxx.ap-northeast-1.elb.amazonaws.com. Stack (svc) Service ʹ֘౰͢ΔCFn Stack ͕࡞੒ ల։ ˞Ϗϧυ͞Εͨίϯςφ΋σϓϩΠ͞ΕΔ αʔϏεͷΤϯυϙΠϯτ͕දࣔ Stack (env) Stack (app)
  58. Cloud Formation Stack app ├ copilot │ └ front-end │

    └ manifest.yml ├ Dockerfile └ src ├ hoge.js : > copilot init Application name: copilot-app Service type: Load Balanced Web Service Service name: front-end Dockerfile: ./Dockerfile Ok great, we'll set up ... Deploy: Yes ⠙ Creating the infrastructure ... ✓Deployed front-end, you can access it at http://xxxxxx.ap-northeast-1.elb.amazonaws.com. Stack (svc) Stack (env) Stack (app) ͍ͬͨΜ·ͱΊ ͭͷ޻ఔͰϓϩμΫγϣϯϨσΟͳίϯςφΞʔΩςΫνϟ͕࡞੒Մೳ
  59. ͦΖͦΖ ϝΠϯσΟογϡͷ͓࣌ؒͰ͢ɻ ʢϋϚίʔγΣϑʹΑΔ՚ྷͳΔσϓϩΠΛͲ͏ͧʣ ຊ೔ͷϝχϡʔΛ͝঺հͨ͠ͱ͜ΖͰʜ σϞ

  60. AWS Copilot ・ECS & Fargate 構築とアプリ自動デプロイが可能なツール ɾͭ޻ఔͰϓϩμΫγϣϯϨσΟͳ؀ڥ͕४උ ɾγϯϓϧͳ CI/CD ύΠϓϥΠϯ΋༻ҙՄೳ

    ͓·͚ͷσβʔτ
  61. Pipeline ίϯςφ CI/CD ༻ͷϦιʔεఆٛ ɾ CodePipeline ʹΑΔύΠϓϥΠϯͷϕʔε͕؅ཧ͞ΕΔɻ ɾෳ਺ Environment ͰͭͷύΠϓϥΠϯͷΈαϙʔτɻ

  62. Pipeline CodePipeline 〜 CodeBuild 〜 CloudFormation ͷ CI/CD ͕ల։ɻ ݱ࣌఺Ͱιʔεεςʔδ͸

    GitHub ͷΈɻ
  63. Application Environment Service Application Service Service Environment Environment Environment

  64. pipeline Application Environment Service Application Service Service Environment Environment Environment

  65. pipeline Application PoC ؀ڥ サンプルAPI Application όοΫΤϯυ"1* 8FC"1* ։ൃ؀ڥ εςʔδϯά؀ڥ

    ຊ൪؀ڥ
  66. ·ͱΊ

  67. AWS Copilot ・ECS & Fargate 構築とアプリ自動デプロイが可能なツール ɾͭ޻ఔͰϓϩμΫγϣϯϨσΟͳ؀ڥ͕४උ ɾγϯϓϧͳ CI/CD ύΠϓϥΠϯ΋༻ҙՄೳ

    ·ͱΊ
  68. ׬৯͍͖ͨͩ ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ JAWS SONIC 2020