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
Terraform で作る Amazon ECS の CI/CD パイプライン
Search
hiyanger
January 18, 2025
Programming
460
1
Share
Terraform で作る Amazon ECS の CI/CD パイプライン
栃木ゆる勉強会(2025/1/18)
https://tochigi-study.connpass.com/event/337526/
登壇 / 20分
hiyanger
January 18, 2025
More Decks by hiyanger
See All by hiyanger
SREに優しいTerraform構成 modulesとstateの組み方
hiyanger
2
160
Terraform やるなら公式スタイルガイドを読もう 〜重要項目 10選〜
hiyanger
14
3.9k
(Amazon Bedrock 基礎)生成 AI の活用に導くシステム構築の基本とセキュリティの実装
hiyanger
4
130
CIer に在籍した 3年間 でやったこと
hiyanger
2
350
これからクラウドエンジニアになるために本当に必要なスキル 5選
hiyanger
1
780
クラウド食堂とは?
hiyanger
0
420
Amazon ECS とマイクロサービスから考えるシステム構成
hiyanger
2
1.5k
全身全霊で取り組んだ 2024 Qiita アドベントカレンダー
hiyanger
0
120
【AWS】EC2 基本アーキテクチャ(ハンズオン付き)
hiyanger
0
240
Other Decks in Programming
See All in Programming
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
710
セグメントとターゲットを意識するプロポーザルの書き方 〜採択の鍵は、誰に刺すかを見極めるマーケティング戦略にある〜
m3m0r7
PRO
0
710
【26新卒研修資料】TDD実装演習
dip_tech
PRO
0
140
Vibe NLP for Applied NLP
inesmontani
PRO
0
560
Spec-driven Development: How AI Changes Everything (And Nothing)
simas
PRO
0
530
運転動画を検索可能にする〜Cosmos-Embed1とDatabricks Vector Searchで〜/cosmos-embed1-databricks-vector-search
studio_graph
1
540
PHPer、Cloudflare に引っ越す
suguruooki
1
120
[RubyKaigi 2026] Require Hooks
palkan
1
270
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
920
第3木曜LT会 #28
tinykitten
PRO
0
120
AWSコミュニティ活動は顧客のクラウド推進に効くのか / Do AWS community activities help customers adopt the cloud?
seike460
PRO
0
160
How We Practice Exploratory Testing in Iterative Development( #scrumniigata ) / 反復開発の中で、探索的テストをどう実施しているか
teyamagu
PRO
2
370
Featured
See All Featured
Information Architects: The Missing Link in Design Systems
soysaucechin
0
910
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Un-Boring Meetings
codingconduct
0
280
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
SEO for Brand Visibility & Recognition
aleyda
0
4.5k
Chasing Engaging Ingredients in Design
codingconduct
0
180
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.7k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
190
The Limits of Empathy - UXLibs8
cassininazir
1
320
Balancing Empowerment & Direction
lara
6
1.1k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Transcript
Terraform で作る Amazon ECS の CI/CD
自己紹介 名前 / 檜山 準(ひやんが / hiyanger) 職種 / AWS
エンジニア 所属 / クラウド系 SIer 出身 / 栃木県 宇都宮市 趣味 / ギター 🎸 @hiyanger
自己紹介 出身 / 宇都宮 錦小学校 陽北中学校 宇都宮北高
自己紹介 名前 / 檜山 準(ひやんが / hiyanger) 職種 / AWS
エンジニア 所属 / クラウド系 SIer 出身 / 栃木県 宇都宮市 趣味 / ギター 🎸 @hiyanger
自己紹介 AWS でやってきたこと 現 SIer には 2022/12 入社 そこから AWS
をさわり始める
自己紹介 本日は改めて ご参加ありがとうございます! うーたんさんとの初回は東京の LT会、めぐろ LT 会にて。 その後、企画からお誘いいただ きました🙏
Terraform で作る Amazon ECS の CI/CD
はじめに ※補足 各用語の概要 Terraform コードでインフラが作れる IaC のひとつ。コードはインフラエ ンジニアにも優しい。 ECS AWS
で使われるコンテナの代 表格。オーケストレーション的 なこともできちゃう。 CI/CD コードの変更からビルド、テス ト、デプロイまで自動化。
もくじ 1. どのような CI/CD パイプラインを作るかの検討 2. 実際に CI/CD パイプラインを構築
1.どのような CI/CD パイプライン を 作るかの検討
どのような CI/CD パイプラインを作るかの検討 もくじ 1. GitHub Actions のみ 2. AWS
Code シリーズ のみ 3. GitHub Actions + AWS Code シリーズ
どのような CI/CD パイプラインを作るかの検討 1. GitHub Actions のみ メリット .yml 1つで完結する
デメリット ・AWS との複数の API 連携で処理が増える ・Blue/Green が できなさそう
どのような CI/CD パイプラインを作るかの検討 2. AWS Codeシリーズ のみ メリット ・他サービスと 連携しやすいし柔軟
・Blue/Green、ロール バックも可能 デメリット IAM ロールの管理が 増える
どのような CI/CD パイプラインを作るかの検討 3. GitHub Actions + AWS Codeシリーズ メリット
・単独で使う場合の 煩雑性を解消できる ・アプリとインフラの境 界を明確にできる💡 デメリット 両方の管理が必要
どのような CI/CD パイプラインを作るかの検討 アプリとインフラの境界を明確化(例) アプリは GitHub Actions!インフラは Code シリーズ! appspec.yml
migrations.sql dockerfile 等 pipeline.tf
2. 実際に CI/CD パイプラインを 構築
実際に CI/CD パイプラインを構築 構成図 💡ポイント💡 ・アプリとインフラが いる ・GHA と Code
シリーズ が混在
実際に CI/CD パイプラインを構築 構築のながれ 1. GitHub Actions 2. 基本リソースの作成 3.
AWS Code シリーズ
実際に CI/CD パイプラインを構築 1. GitHub Actions ・dockerfile から docker image
をビルド ・docker image を ECR に push (💡OIDC 接続 / AWS クレデンシャル配置不要) ・migrations.sql を S3 へ配置 OIDC
はじめに 1. GitHub Actions / Terraform(IAMロール) OIDC で GitHub からの
アクセスを許可💡
実際に CI/CD パイプラインを構築 2.基本リソースの作成 ・ECS ・VPC ・RDS ・ALB ・S3 VPC
VPC
はじめに 2.基本リソースの作成 / Terraform(ECS) deployment_conrroller は CODE_DEPLOY💡
実際に CI/CD パイプラインを構築 3. AWS Code シリーズ ・CodePipeline ・CodeBuild 💡RDS
が プライベートサブネットに あると VPC への配置と NAT GW が必要 ・CodeDeploy 💡ログがないのでエラーがでるとつらい
実際に CI/CD パイプラインを構築 3. AWS Codeシリーズ / Terraform(CodeDeploy) ロールバックや、 Blue/Green
はここで設定💡
実際に CI/CD パイプラインを構築 パイプラインを流してみる ECR へプッシュ DB マイグレーション ECS デプロイ
ECR からトリガー
参考 ・より詳細な自分の Qiita 記事(GHA やTerraformのコードはこちらから) 【AWS】ECS CI/CD の作り方(GitHub Actions /
Code シリーズ / Terraform) https://qiita.com/hiyanger/items/05d9203048d09da28288 ・ECS用のCDパイプラインに対する考察 https://zenn.dev/reireias/articles/8e987af2762eaa#3.-image-build%E3%81%AE%E3%81% BFgithub-actions%E3%81%A7%E3%82%84%E3%82%8B ・AWSとGitHubを用いたパターン別CI/CD構成解説 https://speakerdeck.com/tsukuboshi/cdgou-cheng-jie-shuo?slide=29 ・GitHub Actions から ECR に Docker イメージを push する https://zenn.dev/kou_pg_0131/articles/gh-actions-ecr-push-image#1.-github-actions-%E 7%94%A8%E3%81%AE-id-%E3%83%97%E3%83%AD%E3%83%90%E3%82%A4%E3%83%80 %E3%81%A8-iam-%E3%83%AD%E3%83%BC%E3%83%AB%E3%82%92%E4%BD%9C%E6%88 %90%E3%81%99%E3%82%8B
以上です。 ありがとうございました! 今後とも「栃木ゆるIT勉強会」を よろしくおねがいします!