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
ECS Service Connect By Terraform
Search
kamadakohei
December 20, 2022
Technology
1.4k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ECS Service Connect By Terraform
JAWS-UGコンテナ支部 #22 re:CapのLTでの発表資料
kamadakohei
December 20, 2022
More Decks by kamadakohei
See All by kamadakohei
FargateのPID namespace sharing を試してみた
kamadakohei
0
1.6k
Amazon CloudWatch Syntheticsで始める合成監視
kamadakohei
0
620
Amazon VPC Latticeを触ってみた!
kamadakohei
0
1.1k
AIアプリ作ってみた
kamadakohei
0
530
LINEBot作ってみた
kamadakohei
0
110
Other Decks in Technology
See All in Technology
AIテスト自動化と評価駆動開発EDD
happysamurai294
0
130
Flutter Widget Previewerで始めるUIプレビューとVRTの自動化
sakusaku3939
0
190
ドメインエキスパートは いかにして AI を使って プロダクト開発をするか
tatsuyashiraishi
1
250
素人でもできた!AIを使った短編小説創作入門
delhi09
PRO
0
280
E2Eってつらくないですか?E2Eの管理コストを下げる手段とその実践
akaboshinit
6
2.9k
AI時代のエンジニアの情報発信〜個人の発信を組織の力に変える〜
ryo_kawamata
0
6.6k
AIコーディングエージェント開発_全体像
happysamurai294
0
150
ALBのLCU予約とトラフィックの波によるプロダクト理解 / Understanding ALB LCU and Traffic Spikes
mito201
1
130
Jev の中身は50行で再現できる。でも本物との差はどこにあるのか
hisuzuya
0
280
キヨさん、67歳。AIコーディングエージェントに挑む
happysamurai294
0
140
なぜ東京にいる私が、新潟の技術コミュニティを運営するのか by 八雲慎之助
yakumo
0
210
AIがGISを代替する日:〜すべてをAIが創る時代に、私たちがFOSS4Gに関わる意味〜
lehupa
0
190
Featured
See All Featured
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
520
It's Worth the Effort
3n
188
29k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.4k
Paper Plane (Part 1)
katiecoart
PRO
2
12k
WENDY [Excerpt]
tessaabrams
14
40k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
370
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
730
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
240
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
2
2.1k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
570
Transcript
ECS Service Connect by Terraform
⾃⼰紹介 名前: 釜⽥康平(Kamada Kohei) 職種:サーバーサイドエンジニア 趣味:ランニング
ECS Service Connect マイクロサービスアーキテクチャなどの構成でECS間の通信を簡単に設定できるようにしたもの。 従来のECS間の通信⼿法との違いはスライド「ECS Service Connectによるサービスの新しいつなぎ ⽅」が詳しい。 https://speakerdeck.com/iselegant/a-new-way-to-connect-services-with-ecs-service-connect
Terraformで試してみた CDKとCLIは既に試している⽅がいたので 私はTerraformで試してみました。 https://github.com/hashicorp/terraform-provider-aws/issues/28043
構成図 以下の構成で試してみました。 • 同じ名前空間(connect)内にクライアントとサーバー⽤の ECSサービスが1つずつ存在する。 • クライアント、サーバーともにApacheのコンテナイメージ ※参考:「 ECS Service
ConnectをCDKでデプロイしてみた」 https://dev.classmethod.jp/articles/ecs-service-connect- cdk/
流れ •Terraform • VPC・サブネット作成 • Cloud Mapで名前空間作成 • ECSクラスター作成 •
ECSのタスクを定義 • サーバーコンテナのECSサービス、クライアントコンテナのECSサー ビス作成
VPC・サブネット作成 module "vpc" { source = "terraform-aws-modules/vpc/aws" version = "3.10.0"
name = "my-vpc" cidr = "10.0.0.0/16" enable_dns_hostnames = true enable_dns_support = true azs = ["ap-northeast-1a", "ap-northeast-1c"] public_subnets = ["10.0.11.0/24", "10.0.12.0/24"] } Terraform RegistryのAWSモジュールを利⽤して作成
Cloud Mapで名前空間作成 resource "aws_service_discovery_http_namespace" ”connect" { name = ”connect" }
「インスタンスの検出」が「API呼び出し」になる名前空間リソースを作成 ※CDKやCLIと違い、Terraformはクラスター作成時に 別途作成してくれるオプションがないので別途作成する必要がある。
ECSクラスター作成 resource "aws_ecs_cluster" "cluster" { name = "connect-cluster" }
タスク定義(定義部分のみ抜粋) container_definitions = jsonencode([ { name = "webserver", image =
"public.ecr.aws/docker/library/apache:latest", essential = true portMappings = [ { // ServiceConnectで使うために名前が必要 name = ”webserver” containerPort = 80 protocol = "tcp” // ServiceConnectの envoyがこのプロトコルでproxyする appProtocol = "http" } ] essential = true logConfiguration = { "logDriver" = "awslogs" "options" = { "awslogs-group" = "ecs/connect" "awslogs-region" = "ap-northeast-1" "awslogs-stream-prefix" = ”apache" } } } ])
ECSサービス(サービスコンテナ側)作成 service_connect_configuration { enabled = true namespace = "arn:aws:servicediscovery:ap-northeast-1:xxxxxxxxxx:namespace/xxxx” //
ServiceConnectで構築されるEnvoyのログ設定 log_configuration { log_driver = "awslogs" options = { awslogs-group = "/ecs/connect-server" awslogs-region = "ap-northeast-1" awslogs-stream-prefix = "ecs-proxy" } } service { client_alias { port = 80 } // task定義のportMappingsで定義した名前(宛先コンテナ) port_name = "webserver" } }
ECSサービス(クライアントコンテナ側)作成 service_connect_configuration { enabled = true namespace = "arn:aws:servicediscovery:ap-northeast-1:xxxxxxxxxx:namespace/xxxx” //
ServiceConnectで構築されるEnvoyのログ設定 log_configuration { log_driver = "awslogs" options = { awslogs-group = "/ecs/connect-client" awslogs-region = "ap-northeast-1" awslogs-stream-prefix = "ecs-proxy" } } } ※Serviceを省略することでクライアントコンテナとして作成される
動作確認 クライアントコンテナにECS Execで⼊ってcurlで動作確認でき るはずだが・・ うまくコンテナが⽴ち上がらず・・
気づいたこと • ECS Service Connectを扱う上での前提知識が多い。 (Cloud Map, Envoyなど) →前提知識を勉強してから触った⽅が良い。 •
ECS Service Connectの設定値の意味を理解する必要がある。
参考 • ECS Service Connectによるサービスの新しいつなぎ⽅ https://speakerdeck.com/iselegant/a-new-way-to-connect- services-with-ecs-service-connect • ECS Service
ConnectをCDKでデプロイしてみた https://dev.classmethod.jp/articles/ecs-service-connect- cdk/#toc-3 • Amazon ECS Service Connectのメモ https://zenn.dev/fujiwara/scraps/eea64fd3215e95