Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Terraform で作る Amazon ECS の CI/CD パイプライン
Search
hiyanger
January 18, 2025
Programming
580
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
280
Terraform やるなら公式スタイルガイドを読もう 〜重要項目 10選〜
hiyanger
14
4.2k
(Amazon Bedrock 基礎)生成 AI の活用に導くシステム構築の基本とセキュリティの実装
hiyanger
4
160
CIer に在籍した 3年間 でやったこと
hiyanger
2
470
これからクラウドエンジニアになるために本当に必要なスキル 5選
hiyanger
1
850
クラウド食堂とは?
hiyanger
0
510
Amazon ECS とマイクロサービスから考えるシステム構成
hiyanger
2
1.6k
全身全霊で取り組んだ 2024 Qiita アドベントカレンダー
hiyanger
0
140
【AWS】EC2 基本アーキテクチャ(ハンズオン付き)
hiyanger
0
380
Other Decks in Programming
See All in Programming
Groovy as a human and AI friendly programming language
paulk
0
140
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
310
contenteditable と日本語入力に向き合う
colorful12
0
230
Jetpack Compose Mechanisms
skydoves
3
900
AI時代のIaC入門 〜なぜインフラをコードで管理したいのか?〜 / Introduction to IaC in the AI Era
akihisaikeda
5
1.3k
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
490
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
2
230
R8 の設定見直しでアプリサイズ削減
andpad
0
240
Web3Dライブラリを作ってVue Custom Rendererの仕組みを理解しよう / lets learn vue custom renderer by making 3d library
drumath2237
1
100
Materialが消えた日 〜真っ白なFlutterキャンバスにRenderObjectで絵を描く〜
umigishiaoi
0
120
Railsのためのパスキー実践入門 〜マルチテナントSaaSでの意思決定〜
utakaha
3
1.8k
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
120
Featured
See All Featured
sira's awesome portfolio website redesign presentation
elsirapls
0
480
Done Done
chrislema
187
17k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.8k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
23k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
Are puppies a ranking factor?
jonoalderson
2
4.1k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
290
Ethics towards AI in product and experience design
skipperchong
2
450
Amusing Abliteration
ianozsvald
1
370
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Leo the Paperboy
mayatellez
10
2.4k
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勉強会」を よろしくおねがいします!