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

CloudFormation Git Syncで始める 
CDK の Pull型デプロイ

mazyu36
February 21, 2024
560

CloudFormation Git Syncで始める 
CDK の Pull型デプロイ

mazyu36

February 21, 2024
Tweet

Transcript

  1. $MPVE'PSNBUJPO $'O ͷ(JU4ZODػೳΛ$%,Ͱ׆༻͢Δ࿩Ͱ͢ɻ w (JU4ZODͷ֓ཁɺԿ͕خ͍͔͠ w $%,ʹ͓͚Δ׆༻ྫ w ྑ͍ͱ͜Ζਏ͍ͱ͜Ζ ຊ೔ͷ಺༰

     IUUQTCJUMZ0.[H$W IUUQTCJUMZ00O( ࡉ͔͍ઃఆํ๏౳͸ϒϩάʹهࡌ͍ͯ͠ΔͷͰ ߹Θͤͯ͝ࢀর͍͚ͨͩΔͱخ͍͠Ͱ͢ɻ
  2. ରԠ͍ͯ͠ΔϓϩόΠμʔ ˞ݱࡏ (JU4ZODͱ͸ Stack  AWS CloudFormation Template AWS Cloud

    GItHub Developer ᶃ$'OUFNQMBUFΛߋ৽ ᶄ$'O͕ߋ৽Λݕ஌ͯ͠QVMM ᶅQVMMͨ͠UFNQMBUFΛݩʹEFQMPZ AWS CodeCommit ରԠͯ͠ͳ͍ͧɻ $'O͕(JU্ͷ5FNQMBUFΛQVMMͯ͠EFQMPZ͢Δػೳɻ ˞͍ΘΏΔ(JU0QTΛ࣮ݱ
  3. $%,Ͱ(JU4ZODΛ࢖͏ʹ͸ Stack  AWS CloudFormation Template AWS Cloud Developer UFNQMBUFΛ߹੒ʢTZOUIʣ͠ɺ(JU্ʹ഑ஔ͢Ε͹ྑ͍

    AWS CDK Template ౰વ͕ͩखݩͰTZOUIͯ͠ QVTIͯ͠΋ྑ͍ GItHub AWS CDK $*ͰUFNQMBUFΛTZOUI ˞ຊࢿྉ͸ͪ͜ΒΛ૝ఆ ˞"TTFUT͕͋Δ৔߹͸QVCMJTI΋ඞཁɻৄࡉޙड़ɻ QVMMͯ͠EFQMPZ
  4. ैདྷͷ$*$%ͱ(JU4ZODͷҧ͍ˠ$*ͱ$%ͷ෼཭ Stack  AWS CloudFormation Template AWS Cloud Developer GItHub

    AWS CDK Stack AWS Cloud Developer GItHub AWS CDK Template synth synth push push deploy deploy pull ैདྷͷ$*$%ʢ$*0QTʣ (JU4ZODʢ(JU0QTʣ $*πʔϧ͕ $% EFQMPZ Λ࣮ࢪɻ $*πʔϧͷ੹຿͸ $* CVJME ·Ͱɻ $%πʔϧ $'O ͕ $% EFQMPZ Λ࣮ࢪɻ ੹຿ͷڥք
  5. $*ͱ$%ͷ෼཭ʹΑΓಘΒΕΔͭͷϝϦοτ Stack  AWS CloudFormation Template AWS Cloud Developer GItHub

    AWS CDK synth push deploy pull (JU4ZODʢ(JU0QTʣ Developer Admin ᶃ$*πʔϧͷݖݶ࠷খԽ w $*πʔϧ͸EFQMPZͷݖݶ͕ෆཁʹͳΔɻ w EFQMPZͷݖݶ͸ڧྗͳͨΊɺ֎͕ͩ͠ ηΩϡϦςΟ্ωοΫʹͳΔ͜ͱ͋Γɻ ᶄ໾ׂ෼୲ͷ໌֬Խ w $*Λ%FWFMPQFSɺ$%Λ"ENJOͷΑ͏ͳ ໌֬ͳ໾ׂ෼୲͕Մೳɻ w $*0QT͸ͭͷύΠϓϥΠϯͱͳΔͨΊɺ ୭͔͕શମΛߏஙɾӡ༻͢Δඞཁ͕͋Δɻ ᶅύΠϓϥΠϯߏஙίετΛʢ΍΍ʣ࡟ݮ w $*ͱ$%ͰύΠϓϥΠϯ͕෼͔Εγϯϓϧʹɻ $%͸QVMMͷઃఆΛ͢Δ͚ͩͳͷͰ͔ͳΓָɻ w ͨͩ͠$*͸ଟগ࡞ΓࠐΈ͕ඞཁɻ τʔλϧͰָͰ͋Δ͔͸ঢ়گ࣍ୈɻ ʢࢲݟʣ্هʹັྗΛײ͡ͳ͍ঢ়گͰ͸ɺੵۃతʹ(JU4ZODΛ࠾༻͢Δཧ༝͸ͳ͍
  6. $%,ʹ͓͚Δ(JU4ZOD׆༻ྫ Developer Stack feature_hoge main push Template Template AWS CloudFormation

    Amazon S3 Amazon ECR Assets AWS Cloud GItHub AWS CDK cdk diff assets publish pull deploy merge push trigger ᶃ ։ൃऀ͸DELEJ ff  Λ֬ೝ͠ͳ͕Β࣮૷ ᶄ 13࡞੒ΛτϦΨʔʹ$*Λ࣮ࢪ w BTTFUTͷQVCMJTI w UFNQMBUFΛTZOUI ᶅNBJOΛQVMMͯ͠EFQMPZ  ˞(JU)VC"DUJPOTϫʔΫϑϩʔͷ಺༰౳ɺৄࡉͳઃఆ͸ϒϩάʹهࡌ
  7. ᶃ։ൃऀ͸DELEJGGΛ֬ೝ͠ͳ͕Β࣮૷ ਖ਼͘͠EJ ff ΛऔΔͨΊʹʮ࣮૷্ͷ4UBDL໊ʯͱʮ$'OͰઃఆ͢Δ4UBDL໊ʯΛἧ͓͑ͯ͘ඞཁ͕͋Δɻ ˞DELEJ ff Λ࢖Θͳ͍৔߹͸ෆཁ  new CdkGitSyncStack(app,

    'CdkGitSyncStack', { stackName: 'CdkGitSyncStack'. // Stack name }); Developer AWS CDK cdk diff HogeStack (CFn্Ͱઃఆͨ͠Stack໊ʣ CdkGitSyncStack (CDK࣮૷্ͷStack໊ʣ 4UBDL໊͕ζϨ͍ͯΔͱʜ (JU4ZODͰEFQMPZ͞Εͯ ͍Δ4UBDL͸ͬͪ͜ɻ DELEJ ff ͷର৅ͷ 4UBDL͸ͬͪ͜ɻ ʢ(JU4ZODͱζϨΔʣ
  8. ᶄ13࡞੒ΛτϦΨʔʹ$*Λ࣮ࢪ "TTFUT -BNCEBͷίʔυ౳ ͕ଘࡏ͢Δ৔߹ɺQVCMJTIΛ࣮ࢪɻ  $*πʔϧͰ$'OUFNQMBUFΛੜ੒͠ɺࣗಈͰQVTIɻ Amazon S3 Amazon ECR

    Assets assets publish Role AssumeRole DELBTTFUTΛ࢖༻ͯ͠QVCMJTI ʢݱࡏɺ௥ՃΠϯετʔϧཁʣ QVCMJTIͷݖݶͷΈ֎ͩ͠ཁɻ ݖݶΛߜΔɺ͔ͭ0*%$ར༻͕๬·͍͠ ʢݖݶ͸ӈهࢿྉ͕ඇৗʹࢀߟʹͳΔʣ IUUQTCJUMZ*.((( DELBTTFUTQVCMJTIQDELPVU$EL(JU4ZOD4UBDLBTTFUTKTPO feature_hoge Template push ੜ੒ͨ͠$'OUFNQMBUFΛࣗಈͰQVTIɻ Ϣʔβʔ͸CPUʹ͍ͯ͠Δɻ ྫͰ͸DELEJ ff ͷ݁ՌΛίϝϯτͰ௥Ճɻ ʢ౰વ͕ͩඞਢͰ͸ͳ͍ʣ
  9. ᶅNBJO΁ͷϚʔδޙQVMMͯ͠EFQMPZ  Stack main Template AWS CloudFormation pull deploy feature_hoge

    merge NBJOϒϥϯνͷUFNQMBUFߋ৽Λ$'O͕ݕ஌ͯ͠EFQMPZ (JU4ZODͰɺNBJOϒϥϯνΛઃఆ͓ͯ͘͠ɻ
  10. $%,ʹ͓͚Δ(JU4ZOD׆༻ྫʢ࠶ܝʣ Developer Stack feature_hoge main push Template Template AWS CloudFormation

    Amazon S3 Amazon ECR Assets AWS Cloud GItHub AWS CDK cdk diff assets publish pull deploy merge push trigger ᶃ ։ൃऀ͸DELEJ ff  Λ֬ೝ͠ͳ͕Β࣮૷ ᶄ 13࡞੒ΛτϦΨʔʹ$*Λ࣮ࢪ w BTTFUTͷQVCMJTI w UFNQMBUFΛTZOUI ᶅNBJOΛQVMMͯ͠EFQMPZ 
  11. ·ͱΊ Stack  AWS CloudFormation Template AWS Cloud Developer GItHub

    AWS CDK synth push deploy pull $*πʔϧͷ੹຿͸ $* CVJME ·Ͱɻ $%πʔϧ $'O ͕ $% EFQMPZ Λ࣮ࢪɻ w (JU4ZODʹΑΓ$*ͱ$%Λ෼཭Ͱ͖ΔɻಛʹηΩϡϦςΟ໘Ͱେ͖ͳϝϦοτ͋Γɻ w BTTFUTͷQVCMJTIͳͲଟগखؒͳ෦෼͸͋Δ͕ɺे෼ʹ࣮༻ՄೳͳϨϕϧɻ ੹຿ͷڥք ϝϦοτΛײͨ͡ํ͸ಋೖΛݕ౼͞ΕͯΈͯ͸͍͔͕Ͱ͠ΐ͏͔ɻ