<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kosuke Ozawa</title>
    <description>The latest articles on DEV Community by Kosuke Ozawa (@kskozw03).</description>
    <link>https://dev.to/kskozw03</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3782183%2Ff65e65ce-3545-4dc5-a859-0c224be34a61.jpeg</url>
      <title>DEV Community: Kosuke Ozawa</title>
      <link>https://dev.to/kskozw03</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kskozw03"/>
    <language>en</language>
    <item>
      <title>Why ECS Exec Fails on ECS Managed Instance and How to Fix It</title>
      <dc:creator>Kosuke Ozawa</dc:creator>
      <pubDate>Fri, 08 May 2026 05:19:16 +0000</pubDate>
      <link>https://dev.to/aws-builders/why-ecs-exec-fails-on-ecs-managed-instance-and-how-to-fix-it-3khg</link>
      <guid>https://dev.to/aws-builders/why-ecs-exec-fails-on-ecs-managed-instance-and-how-to-fix-it-3khg</guid>
      <description>&lt;p&gt;I hit an issue while testing ECS Managed Instance, so here's a quick note for future reference.&lt;/p&gt;

&lt;h2&gt;
  
  
  ECS Exec Fails on a Task Container Running on ECS Managed Instance in a Public Subnet
&lt;/h2&gt;

&lt;p&gt;If you deploy this setup in a public subnet without any special network configuration and run the Exec command, you'll get the following error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;An error occurred &lt;span class="o"&gt;(&lt;/span&gt;TargetNotConnectedException&lt;span class="o"&gt;)&lt;/span&gt; when calling the ExecuteCommand operation: The execute &lt;span class="nb"&gt;command &lt;/span&gt;failed. TargetNotConnected: ecs:ecs-task_xxxxxxxxxxxxxxxx is not connected.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Network Considerations for ECS Managed Instance
&lt;/h2&gt;

&lt;p&gt;The blog post linked below covers this in detail, but it appears that with ECS Managed Instance, you cannot assign a public IP to a task using &lt;code&gt;assignPublicIp=ENABLE&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://zenn.dev/gsk9999/articles/0da047d2cc3b59" rel="noopener noreferrer"&gt;https://zenn.dev/gsk9999/articles/0da047d2cc3b59&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  When Task Instances Are Placed in a Public Subnet
&lt;/h2&gt;

&lt;p&gt;Here is what you can do:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a VPC Endpoint&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5rh3kwmzenvmbb2fiba8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5rh3kwmzenvmbb2fiba8.png" alt="Connect to Session Manager via VPC Endpoint" width="800" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I confirmed this works with my own testing. However, for production use, the &lt;strong&gt;per-hour cost of VPC Endpoints&lt;/strong&gt; is something to keep in mind.&lt;/p&gt;

&lt;h2&gt;
  
  
  When Task Instances Are Placed in a Private Subnet
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The method above&lt;/li&gt;
&lt;li&gt;Or route traffic to the internet via NAT Gateway&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmc30svdu3dgrwxazl3ku.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmc30svdu3dgrwxazl3ku.png" alt="Connect to Session Manager via NAT Gateway" width="800" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I haven't tested this myself, but since the route is established at the network level in this case, it should work in theory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;When using ECS Managed Instance, it's important to pay attention to networking.&lt;/p&gt;

&lt;p&gt;This article doesn't go into detail on this, but the examples above assume &lt;code&gt;awsvpc&lt;/code&gt; mode. Depending on your use case, switching the ECS network mode to &lt;code&gt;bridge&lt;/code&gt; may also be an option.&lt;/p&gt;

&lt;p&gt;For production environments where NAT Gateway or VPC Endpoints are already in place, going with the approach described in the linked blog post is probably the better choice. Note that the linked blog post is written in Japanese.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>containers</category>
      <category>cloud</category>
      <category>networking</category>
    </item>
  </channel>
</rss>
