Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
government-cloud-ecs-iac-cicd
Search
kenicazu
May 09, 2026
7
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
government-cloud-ecs-iac-cicd
kenicazu
May 09, 2026
More Decks by kenicazu
See All by kenicazu
生成 AI を用いた AWS 環境のトラブルシューティング
kenicazu
1
180
20250617_ガバクラ移行と共に考えるアプリケーションのオブザーバビリティ
kenicazu
0
13
T2-5_AWSとオンプレミスで実現するハイブリッド環境におけるコンテナ活用
kenicazu
0
10
Cost Optimization using KEDA/Graviton
kenicazu
0
8
Lambda、ECS、EKS がそれぞれ提供するManaged Instanceの紹介と使い分け
kenicazu
1
440
ステップバイステップで考えるAmazon ECS の CI/CD と IaC
kenicazu
0
87
ECS のコスト最適化に向けて改めて確認したいポイント
kenicazu
0
140
ECS Managed Instance の紹介・Fargateとの違い
kenicazu
2
1.4k
Featured
See All Featured
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
190
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
140
Discover your Explorer Soul
emna__ayadi
2
1.1k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
270
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
230
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
The SEO Collaboration Effect
kristinabergwall1
1
480
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
280
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
Transcript
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. Amazon Confidential and Trademark. ガバメントクラウドで始める CI/CDパイプライン : 明⽇からの実践ガイド 後半パート 2024/11/5 アマゾン ウェブ サービス ジャパン株式会社 パブリックセクター 東 健⼀ 1
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. 東 健⼀ (Kenichi Azuma) <職務内容> • 中央省庁のお客様を担当する ソリューションアーキテクト § デジタル庁、経産省、厚⽣労働省・⽀払基⾦、こども家庭庁、関連外郭団体 の案件を中⼼にご担当させていただいております。 • コンテナ利⽤に関わる案件のご⽀援(EKS、App Runner、ECS) § EKS / Istio によるサービスメッシュ ワークショップ <趣味> • 散歩、家でゆっくりすること、銭湯 是⾮みなさまの知⾒を私も学ばせてください。 本⽇はよろしくお願いいたします︕
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. はじめに
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. はじめに • 今年9⽉に開催された AWS Innovate でお話しした内容をベースにお話しいたします • ⽐較的抽象的な内容となりますが、もし興味がある⽅はご覧いただけますと幸いです。 © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Kenichi Azuma アマゾン ウェブ サービス ジャパン合同会社 ソリューションアーキテクト ステップバイステップで考える Amazon ECS の CI/CD と IaC T 5 - 4
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. はじめに 本パートでは⾚枠の部分にフォーカスし、ECS/CDKを中⼼に説明 Infrastructure as Code (IaC) Step3 Step2 テスト⾃動化 CI/CD Step1 マネージドサービス (コンテナ) マネージドサービス (サーバレス) セキュリティの シフトレフト オブザーバビリティ Git リポジトリ インフラストラクチャ アプリケーション CI/CD パイプライン 設定と Observability IaC を中⼼として チームがコラボレーションする IaC は ガバメントクラウド移⾏ に求められるモダン化の⼟台
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon ECS の IaC と CI/CD について
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon VPC Private subnet Public subnet Amazon ECS でコンテナを動かすまでのステップ Amazon ECS で Web アプリケーションをデプロイする場合・・・ Application Load Balancer Amazon ECR Amazon ECS Image Task Definition Service ② AWS Fargate Amazon RDS ① ③ ④ IAM Role インフラ 担当 アプリ担当 インフラ 担当 ① 関連するリソースの作成 • ECS クラスター、ECR • VPC、RDS 等 アプリ 担当 ② コンテナイメージ Push ③ タスク定義の作成 ④ サービスの作成(デプロイ)
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. ECS で アプリケーションをデプロイするときの選択肢 アプリケーション Task Definition, Service インフラストラクチャ ECS クラスター VPC, ALB, ECR など • ecspresso ( on AWS CodeBuild ) • AWS CodePipeline ECS デプロイ • AWS CodeDeploy ( B/G デプロイ ) • AWS CDK ( on AWS CodeBuild ) • Terraform ( on AWS CodeBuild ) • AWS CodePipeline CloudFormation デプロイ • Amazon CodeCatalyst 管理のスコープをどうするか、デプロイツールで対応しているデプロイ⽅式 (ローリングアップデート、B/G デプロイ等)も踏まえ、ツールを選定 アプリケーション ( ECS サービス ) の 柔軟なデプロイ インフラも含めた 包括的なデプロイ
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. ローリングアップデートと B/G デプロイについて AWS Dev Day 2022 Blue / Green デプロイと安全性と複雑性と まずはローリングアップデート(例︓CodePipeline ECS Deploy アクション)で要件を満たせるか 検証しつつ、プロジェクトやチームの特性を踏まえて判断 -> 特定ユーザ向け(省内利⽤等)の場合は B/G デプロイを選択せずに シンプルな構成を取ることも可能なケースが多いと推察
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. ECS の 環境を CDK で ⼀括管理する CDK Template Amazon ECS • Docker Image Assets コンストラクトなどを使⽤し 、コンテナのビルドも CDK のライフサイクル に含めて実装することが可能 • 必須適⽤テンプレートやその他のインフラストラクチャと同じ様に CDK で管理したいケースや 同⼀のソースコード / リポジトリ で管理したいケースに適⽤可能 v1.0.0 v1.0.0 Task Definition Service Application Load Balancer Amazon RDS Amazon VPC AWS CDK ・・・ Amazon ECR Image GitHub
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. (参考) BLEA の ECS App サンプル BLEA におけるECSアプリケーションのサンプルについても全て CDK で管理 ※ コンテナイメージは Docker Hubから取得して利⽤している
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon VPC Private subnet Public subnet 全て CDK で 管理する場合の注意事項(1/2) • ECS におけるタスク定義やサービス、コンテナイメージ等は VPC や RDS、ECS クラスター といったリソースとはライフサイクル、デプロイの頻度が異なるケースが多い • ⼀⽅で担当チームが分かれている場合は、別チームのデプロイの際にパイプラインが⼀緒に実⾏さ れてしまうため、管理が難しい。(スタックを分ける等で解決可能な場合もある) -> 現場ではインフラチームとアプリチームが分かれていることが多い Application Load Balancer Amazon ECR Amazon ECS Image Task Definition Service Amazon RDS IAM Role 責務︓アプリチーム デプロイ頻度︓⾼ 責務︓インフラチーム デプロイ頻度︓低
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. 全て CDK で 管理する場合の注意事項(2/2) • Docker Image Assets の 仕様に依存したデプロイとなる • ECS の デプロイはローリングアップデートのみ対応 • ⼀時的にPushされるECRリポジトリが作成される / 任意のリポジトリやタグを利⽤できない • cdklabs にある cdk-docker-image-deployment を⽤いることで 任意の ECRリポジトリの利⽤や タグの付与は可能となるが、2024/11時点ではCDKの正式なコンストラクトではない • また、各レイヤーのテスト等をパイプラインに⼊れるとパイプライン全体の実⾏時間が⻑期化する
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. (参考)GCAS におけるリファレンスアーキテクチャ CodeBuildで各種テスト・ コンテナイメージビルド / ブランチごとにデプロイ先を変更 CodeBuildで各種テスト・ cdk deployコマンドの実⾏ / ブランチごとにデプロイ先を変更
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. (参考)GCAS におけるリファレンスアーキテクチャ CodeBuildで各種テスト・ コンテナイメージビルド / ブランチごとにデプロイ先を変更 CodeBuildで各種テスト・ cdk deployコマンドの実⾏ / ブランチごとにデプロイ先を変更 インフラストラクチャとアプリケーションのデプロイを 別のパイプラインとして管理することで柔軟なデプロイを実現
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. (参考)GCAS におけるリファレンスアーキテクチャ CodeBuildで各種テスト・ コンテナイメージビルド / ブランチごとにデプロイ先を変更 CodeBuildで各種テスト・ cdk deployコマンドの実⾏ / ブランチごとにデプロイ先を変更 インフラストラクチャとアプリケーションのデプロイを 別のパイプラインとして管理することで柔軟なデプロイを実現 ↓ いざチャレンジ︕する前に少し整理・注意が必要
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. ECS リソースを管理する際の注意事項 Template v1.0.0 AWS CodeDeploy v1.0.0 IaC による インフラデプロイ 別のデプロイツールによる ECS サービスのデプロイ • CodeDeploy 等の別サービス経由で コンテナイメージや ECS サービスを更新した場合、 タスク定義・サービスの設定が IaC の記述内容と乖離が⽣じる • ECS の設定更新を IaC から実施する際に、 意図せぬ状態となる恐れがある AWS CDK Task Count : 2 Task Def Revision : 1 Application Task Count : 2 Task Def Revision : 2 ↓ Task Def Revision : 4 Task Count : 4 Task Def Revision : 1 Template v1.1.0 v1.1.0 AWS CDK v1.0.1 v1.0.2 v1.0.3 ① ECS サービスを含めた 各リソースのデプロイ ② アプリケーションの変更等に伴い、 コンテナイメージを更新 タスク定義、サービスも併せて更新 ③ 負荷増⼤に伴い、 ECS サービスのタスク数を更新 ④ CDK の⽅ではタスク定義が リビジョン 1 のままとなっており、 デグレーションが発⽣ Infra
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. 対策案 1 サービス、タスク定義は別管理とする AWS Account VPC・Subnet IAM ECS Cluster ECS Service A Task Task ECS Service B Task Task Container Image Container Image インフラストラクチャの IaC で管理するスコープ RDS Security Service ECR Repository Service B Application Infra Repository Service B アプリチーム インフラチーム ② ① Service A Application Service A アプリチーム ② • インフラストラクチャを管理する IaC と ECS サービス、タスク定義は別の管理とする • チームやプロジェクトの特性に応じて ECS サービス毎に異なるデプロイツールを使うことも可能 ecspresso CDK
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS CodePipeline(インフラ) Amazon ECS ・・・ ECS Service ECS Task GitHub (インフラ) AWS CodeBuild AWS CDK AWS CodePipeline(アプリ) AWS CodeBuild Amazon ECR Image アプリ チーム インフラ チーム ①インフラチームが あらかじめ VPC や ECS クラスター、 ECR等を IaC(CDK等)作成 ②-2 アプリチームは開発からテスト、 ECS サービスのデプロイまで⾃分たちで実施 (インフラチームが作成したクラスターや VPC 等を利⽤) ②-1 インフラチームは インフラチームのスコープリソースを 適宜リリース・変更 Application Load Balancer Amazon RDS Amazon VPC GitHub (アプリ) 対策案 1 実装イメージ
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. 対策案 2 コンテナイメージのみ別管理とする AWS Account VPC・Subnet IAM ECS Cluster Task Task Task Task Container Image Container Image インフラストラクチャの IaC で管理するスコープ RDS Security Service ECR Repository Service B Application Infra Repository アプリチーム インフラチーム • コンテナイメージのみ別管理とし、アプリチームはコンテナイメージビルドまで責務を持つ • ECS サービスや新しいイメージを⽤いた タスク定義の更新は インフラストラクチャの IaC で管理 ECS Service A ECS Service B Service A Application ① ② ② ③
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS CodePipeline(インフラ) Amazon ECS ・・・ ECS Service ECS Task AWS CodeBuild AWS CDK AWS CodePipeline(アプリ) AWS CodeBuild Amazon ECR Image アプリ チーム インフラ チーム ①インフラチームが あらかじめ VPC や ECS クラスター、 ECR 等を IaC(CDK 等)作成 ②アプリチームがコードを Push し コンテナイメージを ビルドして ECR に Push イメージタグをインフラチームに連携 GitHub (インフラ) GitHub (アプリ) Application Load Balancer Amazon RDS Amazon VPC ③アプリチームから連携された イメージタグをセットし、 ECS サービスをデプロイ 対策案 2 実装イメージ
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. それぞれの管理⽅法の⽐較 • インフラストラクチャと ECS サービスの設定を含むアプリ ケーションは別のコードベース で管理 • 各チーム、担当が個別にパイプ ラインを管理し、デプロイ • アプリチームはアプリケーショ ンと ECS サービスを管理 • コンテナイメージ(アプリケー ション)以外の ECS サービスを含 めた全リソースを1つのコード ベースで管理 • アプリチームはアプリケーション を管理のみ、コンテナを PUSH す るまでが責務 • インフラチームが ECS サービスを 管理 IaC で全て管理 サービス、タスク定義は別管理 コンテナイメージのみ別管理 管理⽅法はあくまで⼀例。組織やプロジェクトの特性に合わせて導⼊の形式を検討 • IaC でコンテナイメージを 含め、全リソースを1つの コードベースで管理 • 1 チームで デプロイ • インフラ、アプリケーション、 ECS の設定を全て管理 コードの 管理 チームの 責務 ツールの 選定 • ツール選定の Ownership を チームに持たせることも可能 • ツール選定の Ownership をチーム に持たせることも可能 • 全て同⼀のツールで管理
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. このあと実際にワークショップで体験しましょう
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. このあと実際にワークショップで体験しましょう アプリチーム (プロジェクト個別) インフラチーム (プロジェクト個別) インフラチーム (プロジェクト共通) ステージング環境 インフラチーム (プロジェクト共通)
© 2024, Amazon Web Services, Inc. or its affiliates. All
rights reserved. © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. ありがとうございました