Neil Kuan
January 17, 2026

New 2025 Amazon ECS Managed Instance Support

Posted on January 17, 2026  •  8 minutes  • 1663 words

sources:

Fast Nginx Task Startup with ECS Managed Instances

使用 ECS Managed Instances 快速啟動 Nginx 任務

This project demonstrates how to use Amazon ECS Managed Instances with Terraform to quickly bring up an ECS service running Nginx. 本專案展示如何使用 Terraform 搭配 Amazon ECS Managed Instances 快速啟動運行 Nginx 的 ECS 服務。

We also measure how long it takes from requesting a single task to the moment the application starts logging — roughly 40 seconds end-to-end. 我們也測量了從請求單一任務到應用程式開始記錄日誌所需的時間 — 端到端大約 40 秒


Why Care About ECS Managed Instances?

為什麼要關心 ECS Managed Instances?

When running workloads (tasks / services) on ECS, we typically think in terms of two classic options: 當在 ECS 上運行工作負載(任務/服務)時,我們通常會想到兩種經典選項:

ECS Managed Instances sit somewhere in between: ECS Managed Instances 介於兩者之間:

For SREs/platform teams, this means: 對於 SRE/平台團隊來說,這意味著:


Terraform Example: Architecture Overview

Terraform 範例:架構概述

Demo Repo: https://github.com :neilkuan/ecs-managed-instance-issue

git clone https://github.com:neilkuan/ecs-managed-instance-issue

The main.tf file wires everything together in ap-east-2. At a high level it does the following: main.tf 檔案在 ap-east-2 區域將所有元件串接在一起。在高層次上,它執行以下操作:

In other words, with a single terraform apply you get: 換句話說,透過單一 terraform apply 您可以獲得:

Example Deploy Demo Infra

# init 
terraform init

# apply
terraform apply

# Destroy
terraform destroy

Measuring Cold Start: From Requesting 1 Task to Nginx Logging

測量冷啟動:從請求 1 個任務到 Nginx 記錄日誌

To understand the cold-start behavior of Managed Instances, we used a small script that continuously lists container instances in the cluster. 為了了解 Managed Instances 的冷啟動行為,我們使用了一個小腳本持續列出叢集中的容器實例。

Monitoring Script

監控腳本

bash -c 'while true; do date && aws ecs list-container-instances --cluster managed-instances-cluster;done'

This prints the current time and the result of aws ecs list-container-instances every second so we can see: 這會每秒列印當前時間和 aws ecs list-container-instances 的結果,讓我們可以看到:

Timeline and Results

時間線和結果

Here’s the timeline from “requesting 1 Nginx task” to “Nginx starting to write logs”: 以下是從「請求 1 個 Nginx 任務」到「Nginx 開始寫入日誌」的時間線:

17:04:46 request 1 task 
-> (19s)
17:05:5 container instance running (c6g.large) 
-> (15s)  (pending) -> (running)
17:05:20 task running 
-> (7s)
17:05:27 application (nginx) logging

Interpreted step-by-step: 逐步解讀:

So, from “no container instances at all” to “Nginx actually serving and logging” you’re looking at roughly: 因此,從「完全沒有容器實例」到「Nginx 實際服務並記錄日誌」大約需要:

19s (bring up EC2 + register) + 15s (pull image & start container) + 7s (app startup & first logs) ≒ 41 seconds 19 秒(啟動 EC2 + 註冊)+ 15 秒(拉取映像檔 & 啟動容器)+ 7 秒(應用程式啟動 & 首次日誌)≒ 41 秒

For many back-office services, internal tools, or low-QPS control-plane style workloads: 對於許多後台服務、內部工具或低 QPS 控制平面類型的工作負載:


When to Consider ECS Managed Instances

何時考慮使用 ECS Managed Instances

Some scenarios where ECS Managed Instances can be a great fit: 以下是 ECS Managed Instances 非常適合的一些場景:

If you’re already familiar with ECS on EC2 or Fargate and want a more hands-off way of managing EC2 capacity, this ecs-mg example is a good starting point. 如果您已經熟悉 ECS on EC2 或 Fargate,並且想要一種更省事的 EC2 容量管理方式,這個 ecs-mg 範例是一個很好的起點。

Just run terraform apply, watch the cluster come to life, and observe how Managed Instances handle capacity and cold starts for your Nginx service. 只需執行 terraform apply,觀察叢集啟動,並觀察 Managed Instances 如何為您的 Nginx 服務處理容量和冷啟動。


Findings / 發現一些事情

1. ECS Service Connect with ECS Exec on Managed Instance has connection issues

1. 當 ECS Service Connect 與 ECS Exec 同時啟用時,Managed Instance 上的 Task 無法正常連線

If you deploy this Terraform example repo, the nginx-service will enable both ECS Service Connect and ECS Exec running on Managed Instance.

如果你部署了這個 Terraform 範例,nginx-service 會同時開啟 ECS Service Connect 以及 ECS Exec,並運行於 Managed Instance 上。

Example / 範例:

aws ecs list-services --cluster managed-instances-cluster --region ap-east-2 --query 'serviceArns[]' --output table
# ------------------------------------------------------------------------------------------------
# |                                         ListServices                                         |
# +----------------------------------------------------------------------------------------------+
# |  arn:aws:ecs:ap-east-2:012345678912:service/managed-instances-cluster/nginx-service-exec-ok  |
# |  arn:aws:ecs:ap-east-2:012345678912:service/managed-instances-cluster/nginx-service-fargate  |
# |  arn:aws:ecs:ap-east-2:012345678912:service/managed-instances-cluster/nginx-service          |
# +----------------------------------------------------------------------------------------------+

bash scripts/check-exec-connect.bash \
  --cluster managed-instances-cluster \
  --region ap-east-2 \
  --service nginx-service


The nginx-service-exec-ok service only enables ECS Exec running on Managed Instance.

nginx-service-exec-ok 服務僅開啟 ECS Exec,運行於 Managed Instance 上。

Example / 範例:

bash scripts/check-exec-connect.bash \
  --cluster managed-instances-cluster \
  --region ap-east-2 \
  --service nginx-service-exec-ok


The nginx-service-fargate service enables both ECS Service Connect and ECS Exec running on Fargate.

nginx-service-fargate 服務同時開啟 ECS Service Connect 以及 ECS Exec,運行於 Fargate 上。

Example / 範例:

bash scripts/check-exec-connect.bash \
  --cluster managed-instances-cluster \
  --region ap-east-2 \
  --service nginx-service-fargate


Summary Table / 總結表格

Service Name Launch Type ECS Service Connect ECS Exec Result
nginx-service Managed Instance (EC2) ✅ Enabled ✅ Enabled Connection Failed
nginx-service-exec-ok Managed Instance (EC2) ❌ Disabled ✅ Enabled Works
nginx-service-fargate Fargate ✅ Enabled ✅ Enabled Works
服務名稱 啟動類型 ECS Service Connect ECS Exec 結果
nginx-service Managed Instance (EC2) ✅ 啟用 ✅ 啟用 連線失敗
nginx-service-exec-ok Managed Instance (EC2) ❌ 停用 ✅ 啟用 正常
nginx-service-fargate Fargate ✅ 啟用 ✅ 啟用 正常

Architecture Diagram / 架構意象圖

Conclusion / 結論

Issue: When both ECS Service Connect and ECS Exec are enabled on a Managed Instance (EC2), the ECS Exec connection fails.

問題:當 Managed Instance (EC2) 同時啟用 ECS Service Connect 與 ECS Exec 時,ECS Exec 連線會失敗。

Workaround: Either disable ECS Service Connect on Managed Instance, or use Fargate instead.

解決方法:在 Managed Instance 上停用 ECS Service Connect,或改用 Fargate。

🚨🚨🚨 This issue was reported to AWS Support on 2025/12/25 and is currently awaiting a response.

🚨🚨🚨 該問題已經在 2025/12/25 回報給 AWS Support,目前等待回應中

2026-01-17 Neil Kuan Updated

Follow me

Here's where I hang out in social media