<?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: Rafagross</title>
    <description>The latest articles on DEV Community by Rafagross (@rafagross).</description>
    <link>https://dev.to/rafagross</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1041701%2F478e8253-afa1-41a1-be42-69758a77c15f.png</url>
      <title>DEV Community: Rafagross</title>
      <link>https://dev.to/rafagross</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rafagross"/>
    <language>en</language>
    <item>
      <title>EC2 Instance Unreachable via SSM Session Manager</title>
      <dc:creator>Rafagross</dc:creator>
      <pubDate>Sun, 13 Sep 2026 03:12:04 +0000</pubDate>
      <link>https://dev.to/rafagross/ec2-instance-unreachable-via-ssm-session-manager-1fe9</link>
      <guid>https://dev.to/rafagross/ec2-instance-unreachable-via-ssm-session-manager-1fe9</guid>
      <description>&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;This runbook resolves the situation where an EC2 instance is running and visible in the console but either does not appear in the Systems Manager Fleet Manager inventory, or returns a connection error when you attempt to start a Session Manager session.&lt;/p&gt;




&lt;h2&gt;
  
  
  When to Use This Runbook
&lt;/h2&gt;

&lt;p&gt;Use this runbook when you observe any of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Session Manager shows "Instance not connected" or "Unable to start session"&lt;/li&gt;
&lt;li&gt;The instance does not appear in &lt;strong&gt;Systems Manager → Fleet Manager → Managed Nodes&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ssm:StartSession&lt;/code&gt; returns &lt;code&gt;TargetNotConnected&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;A previously working instance stopped responding to SSM after a restart, IAM change, or network modification&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 1: Verify Instance State
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Console path:&lt;/strong&gt; EC2 → Instances → [Instance ID]&lt;/p&gt;

&lt;p&gt;Confirm the instance is in &lt;code&gt;running&lt;/code&gt; state and that both &lt;strong&gt;Status checks&lt;/strong&gt; show 2/2 passed.&lt;/p&gt;

&lt;p&gt;If status checks are failing, stop here and use the EC2 Status Check runbook. SSM is irrelevant if the instance itself is impaired.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Expected result:&lt;/strong&gt; Instance state = &lt;code&gt;running&lt;/code&gt;, 2/2 status checks passed.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 2: Check SSM Managed Node Status
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Console path:&lt;/strong&gt; Systems Manager → Fleet Manager → Managed nodes&lt;/p&gt;

&lt;p&gt;Search for the instance ID. If it does not appear, or shows &lt;code&gt;Connection Lost&lt;/code&gt;, the issue is one of: missing IAM role, stopped SSM agent, or blocked network path.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Expected result:&lt;/strong&gt; Instance appears with status &lt;code&gt;Online&lt;/code&gt;. If missing or &lt;code&gt;Connection Lost&lt;/code&gt;, continue to Step 3.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3: Verify IAM Instance Profile
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Console path:&lt;/strong&gt; EC2 → Instances → [Instance ID] → Security tab → IAM Role&lt;/p&gt;

&lt;p&gt;The instance must have an IAM role attached with the &lt;code&gt;AmazonSSMManagedInstanceCore&lt;/code&gt; managed policy (or equivalent custom policy granting the minimum SSM actions).&lt;/p&gt;

&lt;p&gt;Minimum required IAM actions if using a custom policy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssm:UpdateInstanceInformation
ssm:ListInstanceAssociations
ssm:DescribeInstanceProperties
ssm:DescribeDocumentParameters
ssmmessages:CreateControlChannel
ssmmessages:CreateDataChannel
ssmmessages:OpenControlChannel
ssmmessages:OpenDataChannel
ec2messages:AcknowledgeMessage
ec2messages:DeleteMessage
ec2messages:FailMessage
ec2messages:GetEndpoint
ec2messages:GetMessages
ec2messages:SendReply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; IAM propagation delay:&lt;br&gt;
IAM role changes applied to a running instance take effect on next SSM agent heartbeat, typically within 2-3 minutes. If you just updated the role, wait 5 minutes and re-check Fleet Manager before continuing.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Expected result:&lt;/strong&gt; IAM role attached with &lt;code&gt;AmazonSSMManagedInstanceCore&lt;/code&gt; or equivalent. If missing, attach the role and wait 5 minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Check SSM Agent on the Instance
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Console path:&lt;/strong&gt; EC2 → Instances → [Instance ID] → Actions → Monitor and troubleshoot → Get system log&lt;/p&gt;

&lt;p&gt;Look for lines referencing &lt;code&gt;amazon-ssm-agent&lt;/code&gt;. A healthy agent shows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight systemd"&gt;&lt;code&gt;&lt;span class="err"&gt;amazon-ssm-agent.service:&lt;/span&gt; &lt;span class="err"&gt;active&lt;/span&gt; &lt;span class="err"&gt;(running)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Errors to look for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Failed to start Amazon SSM Agent&lt;/code&gt; — agent start failure, likely OS-level issue&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Error connecting to endpoint&lt;/code&gt; — network path problem (proceed to Step 5)&lt;/li&gt;
&lt;li&gt;No SSM lines at all — agent not installed or not running&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the agent is not running, you can use EC2 Run Command with &lt;code&gt;AWS-RunShellScript&lt;/code&gt; to restart it — but only if the instance is already registered (partial connectivity). If it's fully unreachable, use EC2 Instance Connect or serial console (if available) to restart manually.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Expected result:&lt;/strong&gt; SSM agent running. No connection errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Diagnose the Network Path
&lt;/h2&gt;

&lt;p&gt;SSM Session Manager requires outbound HTTPS (port 443) from the EC2 instance to three regional endpoints:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Endpoint&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ssm.{region}.amazonaws.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Agent registration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ssmmessages.{region}.amazonaws.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Session data channel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ec2messages.{region}.amazonaws.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;EC2 message delivery&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;For private instances (no NAT Gateway, VPC endpoint required):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Console path:&lt;/strong&gt; VPC → Endpoints&lt;/p&gt;

&lt;p&gt;Verify that all three interface endpoints exist, are associated with the correct VPC, and have status &lt;code&gt;available&lt;/code&gt;. Check that the endpoint security group allows inbound HTTPS from the instance's security group.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Console path:&lt;/strong&gt; VPC → Security Groups → [Endpoint SG]&lt;/p&gt;

&lt;p&gt;Inbound rule required:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight properties"&gt;&lt;code&gt;&lt;span class="py"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HTTPS (443)&lt;/span&gt;
&lt;span class="py"&gt;Source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;[Instance security group ID]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;For instances with NAT Gateway:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Console path:&lt;/strong&gt; VPC → Route Tables → [Instance subnet's route table]&lt;/p&gt;

&lt;p&gt;Confirm a &lt;code&gt;0.0.0.0/0&lt;/code&gt; route pointing to the NAT Gateway exists and the NAT Gateway is in &lt;code&gt;available&lt;/code&gt; state.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;br&gt;
If the instance has a public IP and is in a public subnet with an IGW route, outbound port 443 directly to AWS endpoints is sufficient. No VPC endpoints needed in that case.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Expected result:&lt;/strong&gt; Either VPC endpoints present and &lt;code&gt;available&lt;/code&gt;, or valid NAT/IGW route exists. Instance SG allows outbound 443.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 6: Check Instance Security Group Outbound Rules
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Console path:&lt;/strong&gt; EC2 → Instances → [Instance ID] → Security tab → Security groups → [SG ID] → Outbound rules&lt;/p&gt;

&lt;p&gt;Confirm outbound HTTPS is allowed. The default AWS SG allows all outbound traffic. If rules have been tightened:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight properties"&gt;&lt;code&gt;&lt;span class="py"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HTTPS (443)&lt;/span&gt;
&lt;span class="py"&gt;Destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;0.0.0.0/0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OR (preferred, more restrictive):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight properties"&gt;&lt;code&gt;&lt;span class="py"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HTTPS (443)&lt;/span&gt;
&lt;span class="py"&gt;Destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;[VPC endpoint prefix list or specific endpoint IPs]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Expected result:&lt;/strong&gt; Outbound 443 allowed from instance security group.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 7: Force SSM Agent Re-Registration (Last Resort)
&lt;/h2&gt;

&lt;p&gt;If all above checks pass but the instance still doesn't appear in Fleet Manager, the agent's registration may be stale (common after AMI snapshots or instance cloning).&lt;/p&gt;

&lt;p&gt;Use EC2 Run Command with &lt;code&gt;AWS-RunShellScript&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Amazon Linux 2 / AL2023&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl stop amazon-ssm-agent
&lt;span class="nb"&gt;sudo rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; /var/lib/amazon/ssm/registration
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start amazon-ssm-agent
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status amazon-ssm-agent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wait 2 minutes, then re-check Fleet Manager.&lt;/p&gt;




&lt;h2&gt;
  
  
  Validation Checks
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;th&gt;How to Verify&lt;/th&gt;
&lt;th&gt;Expected Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Instance in Fleet Manager&lt;/td&gt;
&lt;td&gt;SSM → Fleet Manager → search instance ID&lt;/td&gt;
&lt;td&gt;Status: Online&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Session starts&lt;/td&gt;
&lt;td&gt;SSM → Session Manager → Start session → select instance&lt;/td&gt;
&lt;td&gt;Terminal opens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Agent heartbeat&lt;/td&gt;
&lt;td&gt;CloudWatch Logs → /aws/ssm/amazon-ssm-agent&lt;/td&gt;
&lt;td&gt;Recent heartbeat log entries&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Rollback
&lt;/h2&gt;

&lt;p&gt;No destructive changes are made by this runbook. If you attached a new IAM role that you want to remove:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Console path:&lt;/strong&gt; EC2 → Instances → [Instance ID] → Actions → Security → Modify IAM role → No role&lt;/p&gt;




&lt;h2&gt;
  
  
  Escalation
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Condition&lt;/th&gt;
&lt;th&gt;Next Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;All steps pass but instance still unreachable&lt;/td&gt;
&lt;td&gt;Open AWS Support case — provide instance ID, region, VPC endpoint IDs, and CloudWatch agent logs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Agent crashes immediately on start&lt;/td&gt;
&lt;td&gt;Check OS disk space (&lt;code&gt;df -h&lt;/code&gt;), memory, and &lt;code&gt;/var/log/amazon/ssm/amazon-ssm-agent.log&lt;/code&gt; for errors&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Instance in private subnet, no VPC endpoints, no NAT&lt;/td&gt;
&lt;td&gt;Network path is broken by design — work with network team to add VPC endpoints or NAT&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




</description>
      <category>aws</category>
      <category>devops</category>
      <category>linux</category>
      <category>cloud</category>
    </item>
  </channel>
</rss>
