SSM Session Troubleshooter
Quick start
- Symptom → layer map (first plausible match drives the first probe):
instance not in Fleet Manager console → INSTANCE_NOT_REGISTERED
/ AGENT_OUTDATED; session times out after starting →
SESSION_CONNECTION_TIMEOUT / VPC_ENDPOINT_MISSING;
AccessDeniedException on StartSession → IAM_PERMISSION_MISSING;
port forwarding fails to connect → PORT_FORWARDING_FAILURE /
SESSION_CONNECTION_TIMEOUT; ChannelClosedException /
shell-profile errors → SHELL_PROFILE_ERROR; session output not
in S3 → AUDIT_LOG_S3_MISSING / SESSION_RECORDING_S3; CloudWatch
Logs missing → CLOUDWATCH_LOGS_MISSING; session fails during
maintenance window → PATCH_BASELINE_BLOCKING; document schema
error → SESSION_DOCUMENT_ERROR / SSM_DOCUMENT_ERROR.
Moved to references/advanced-patterns.md.
Probe-driven verdicts, the three-endpoint rule for private subnets (missing ssmmessages = session timeouts), AmazonSSMManagedInstanceCore ssmmessages actions, agent version gates (2.3.68.0 sessions / 3.0.196 port-forwarding / 3.1.x macOS).
Mindset
Moved to references/advanced-patterns.md.
SSM service is usually innocent: the broken layer is agent, instance-role IAM, one of the three VPC endpoints, the session document, the shell profile, or the audit-log bucket policy. Start with describe-instance-information, describe-vpc-endpoints, and simulate-principal-policy.
Philosophy
Moved to references/advanced-patterns.md.
Control plane (ssm) vs data plane (ssmmessages) vs ec2messages; registration != session-ready; role gates StartSession AND ssmmessages data channel; session output configured at the document level, not the instance level.
Quick reference — symptom triage table
| Symptom phrase / error |
Most likely layer |
First probe |
Instance absent from Fleet Manager / describe-instance-information returns empty |
INSTANCE_NOT_REGISTERED |
describe-instance-information, EC2 userdata / agent install log |
Instance PingStatus: ConnectionLost / InActive |
INSTANCE_NOT_REGISTERED / AGENT_OUTDATED |
describe-instance-information AgentVersion, LastPingDateTime |
Session starts on client, then "Connection timed out" / ChannelClosedException |
SESSION_CONNECTION_TIMEOUT / VPC_ENDPOINT_MISSING |
describe-vpc-endpoints for ssm/ec2messages/ssmmessages; SG egress to endpoints |
AccessDeniedException on start-session CLI call (caller side) |
IAM_PERMISSION_MISSING (caller) |
iam simulate-principal-policy on the caller's role for ssm:StartSession |
Session starts, agent log shows ssmmessages:OpenDataChannel AccessDenied |
IAM_PERMISSION_MISSING (instance role) |
iam simulate-principal-policy on the instance role for ssmmessages:OpenDataChannel |
| Port forwarding connects but target host unreachable |
PORT_FORWARDING_FAILURE |
ssm start-session document name, target host reachability from the instance |
Port forwarding fails with NotSupported on the agent |
AGENT_OUTDATED |
describe-instance-information AgentVersion < 3.0.196 |
InvalidDocument or InvalidDocumentVersion on session start |
SESSION_DOCUMENT_ERROR / SSM_DOCUMENT_ERROR |
ssm get-document --name SSM-SessionManagerRunShell |
Session opens, exits immediately, amazon-ssm-agent.log shows shell profile error |
SHELL_PROFILE_ERROR |
agent log for SessionTypeHandler / profile errors |
| Sessions work but no JSON output in the S3 session bucket |
AUDIT_LOG_S3_MISSING |
get-document S3 bucket, get-bucket-policy for ssm-output grant |
| Session recording missing from S3; shell scrollback truncated |
SESSION_RECORDING_S3 |
document s3BucketName, KMS key policy, bucket Region |
| Sessions work but CloudWatch Logs group is empty |
CLOUDWATCH_LOGS_MISSING |
document cloudWatchLogGroupName, role logs:CreateLogStream |
Sessions fail during a maintenance window; ScanOnly association in Running state |
PATCH_BASELINE_BLOCKING |
describe-association, describe-instance-associations-status |
| macOS instance cannot start session; agent installed but session API errors |
AGENT_OUTDATED |
AgentVersion < 3.1.x for macOS session support |
| None of the above; region-wide SSM event |
INSUFFICIENT_DATA |
aws health describe-events, AWS Service Health Dashboard |
Pre-flight: instance and session state
Gather the canonical configuration and short-circuit on instance
states that mimic session failures. Misclassifying these produces
hours of session debugging for a problem that is not a session
problem.
Moved to references/diagnostic-commands.md.
Eight probes: describe-instance-information / -properties, describe-sessions, get-document, instance-role simulate-principal-policy (ssm + ssmmessages + s3/logs actions), describe-vpc-endpoints, security-group egress, agent-log filter, AWS Health.
Instance-state short-circuit
PingStatus / describe-instance-information |
Effect on diagnosis |
Online + recent LastPingDateTime |
Agent control channel works; if sessions fail, the issue is data channel, IAM, document, or network — not registration. |
ConnectionLost / InActive |
Agent stopped, instance stopped, or network break. The instance will not appear in Fleet Manager. Start at INSTANCE_NOT_REGISTERED. |
Instance absent from describe-instance-information |
Either the agent is not installed/running, the instance role lacks ssm:UpdateInstanceInformation, or the instance cannot reach ssm.*.amazonaws.com. Start at INSTANCE_NOT_REGISTERED. |
AgentVersion: 2.x.x (below 2.3.68) |
Session Manager not supported on this agent version. Sessions fail with NotSupported or silently. AGENT_OUTDATED. |
AgentVersion: 3.0.x below 3.0.196 |
Port forwarding not supported. PORT_FORWARDING_FAILURE due to AGENT_OUTDATED. |
PlatformName: Mac OS + agent below 3.1.x |
Session Manager not supported on macOS below 3.1. AGENT_OUTDATED. |
If input is malformed (missing InstanceId, absent symptom
description, no document name for document errors), emit:
TARGET: <instance-id or unknown>
VERDICT: INSUFFICIENT_DATA
REASON: Input is missing required context — at minimum a symptom
description (error string or observed behaviour) and the
InstanceId, plus for document/output errors the session document
name and the target S3 bucket or CloudWatch log group.
LAYER: UNKNOWN
EVIDENCE:
- Missing: <list specific missing fields>
REMEDIATION: Re-prompt for: (1) the exact error string or observed
symptom, (2) the InstanceId and platform (Linux / macOS /
Windows), (3) the instance VPC and whether it has internet
access, and (4) for output/audit errors, the session document
name and the target S3 bucket / CloudWatch log group.
Process — Diagnostic decision tree (apply in symptom order)
Symptom-driven. Pick the entry point based on the observed symptom,
then walk the layer-specific probes in order. Never emit
ROOT_CAUSE_IDENTIFIED without a failing probe that matches the
symptom.
Step 0: Non-obvious behaviours that change diagnosis
Moved to references/advanced-patterns.md.
Three-endpoint rule, StartSession on the caller vs ssmmessages on the instance, AmazonEC2RoleforSSM deprecation, agent version floors and self-update via S3, document-carried audit config, shell-profile instant-close, hybrid activation expiry, patch associations slowing the data channel, macOS agent differences, stale Active sessions.
Step 1: Instance registration layer
Entry: instance absent from Fleet Manager /
describe-instance-information returns empty for the instance.
Is the instance running and does it have an instance profile?
aws ec2 describe-instances --instance-ids <i-id> \
--query 'Reservations[0].Instances[0].[State.Name,IamInstanceProfile.Arn]' --output text
- State
stopped → start the instance first.
- No instance profile ARN → the role is missing; attach one.
INSTANCE_NOT_REGISTERED.
Does the instance role include AmazonSSMManagedInstanceCore?
aws iam list-attached-role-policies --role-name <role-name> --output json
- AmazonSSMManagedInstanceCore NOT attached → the agent cannot
call
ssm:UpdateInstanceInformation. INSTANCE_NOT_REGISTERED.
- Legacy
AmazonEC2RoleforSSM → deprecated; switch to
AmazonSSMManagedInstanceCore.
Can the agent reach the SSM endpoint?
- Public subnet: route to IGW; agent reaches
ssm.<region>.amazonaws.com.
- Private subnet with NAT: route to NAT; agent reaches the
public SSM endpoint.
- Private subnet without NAT: needs
ssm, ec2messages, and
ssmmessages interface VPC endpoints.
- VPC endpoint missing → agent never registers.
INSTANCE_NOT_REGISTERED (network).
Is the SSM Agent running on the instance?
On the instance:
sudo systemctl status amazon-ssm-agent # Linux systemd
sudo launchctl list | grep amazon-ssm-agent # macOS
Get-Service AmazonSSMAgent # Windows PowerShell
- Agent not installed or stopped → install or start it.
INSTANCE_NOT_REGISTERED.
For hybrid (non-EC2) instances: is the activation valid?
aws ssm describe-activations --output json
ExpiredDate in the past or RegistrationLimit reached →
the agent cannot re-register after a restart.
INSTANCE_NOT_REGISTERED (hybrid).
If the instance is running, the role is correct, the agent is
installed, but registration still fails, move to the VPC endpoint
layer (Step 5) — the agent may not be reaching ssm.*.
Step 2: IAM permission layer (instance role)
Entry: session starts on the client then times out, or agent log
shows ssmmessages:OpenDataChannel AccessDenied.
aws iam simulate-principal-policy \
--policy-source-arn "<instance-role-arn>" \
--action-names ssm:UpdateInstanceInformation \
ssmmessages:CreateControlChannel ssmmessages:CreateDataChannel \
ssmmessages:OpenControlChannel ssmmessages:OpenDataChannel \
s3:PutObject logs:CreateLogStream \
--output json
- Any action that returns
implicitDeny or explicitDeny confirms
the role is missing the permission. IAM_PERMISSION_MISSING.
ssmmessages:OpenDataChannel denied → session times out within
seconds of starting on the client.
s3:PutObject on the session-output bucket denied → sessions
work but audit logs never land in S3. Cross-reference Step 7.
logs:CreateLogStream denied → sessions work but CloudWatch
Logs group stays empty. Cross-reference Step 9.
For the caller's role (the human or service invoking StartSession):
Moved to references/diagnostic-commands.md.
simulate-principal-policy on the caller's role for ssm:StartSession / ssm:TerminateSession scoped to the instance and SSM-SessionManagerRunShell document ARNs.
ssm:StartSession denied on the caller side → the CLI/API call
returns AccessDeniedException immediately, before any session
is attempted. IAM_PERMISSION_MISSING (caller).
Step 3: VPC endpoint layer
Entry: instance Online (registered) but session times out;
private subnet with no internet egress.
VPC_ID=$(aws ec2 describe-instances --instance-ids <i-id> \
--query 'Reservations[0].Instances[0].VpcId' --output text)
aws ec2 describe-vpc-endpoints --filters Name=vpc-id,Values=$VPC_ID \
--query 'VpcEndpoints[?contains(ServiceName,`ssm`)].[ServiceName,State,VpcEndpointType]' --output table
Required endpoints (interface type) for private-subnet SSM:
| Endpoint service |
Required for |
com.amazonaws.<region>.ssm |
Control plane: registration, StartSession API |
com.amazonaws.<region>.ec2messages |
Run Command / Association delivery |
com.amazonaws.<region>.ssmmessages |
Session data channel (the actual terminal stream) |
- Missing
ssmmessages → session times out within seconds. The
most common SSM session failure. VPC_ENDPOINT_MISSING.
- Missing
ssm → instance never registers (cross-reference Step 1).
- Endpoint present but
State: Pending / Failed → the endpoint
is not yet usable; wait for Available.
Also check the endpoint security group: the VPC endpoint's SG
must allow 443 inbound from the instance's subnet/eni. A VPC
endpoint with no inbound rule on 443 is unreachable from the
instance.
Step 4: Session connection timeout layer
Entry: session starts, then times out; VPC endpoints all present
and IAM passes.
Security group egress on the instance.
aws ec2 describe-security-groups --group-ids <sg-id> \
--query 'SecurityGroups[0].IpPermissionsEgress' --output json
- No egress on 443 to the VPC endpoint CIDRs or the service
ranges → the agent cannot reach
ssmmessages.*.amazonaws.com.
SESSION_CONNECTION_TIMEOUT.
DNS resolution for the endpoint.
- Interface VPC endpoints use private DNS by default. If private
DNS is disabled, the instance resolves
ssmmessages.* to the
public IP and the session fails in a no-egress VPC.
- Check
describe-vpc-endpoints for PrivateDnsEnabled: true.
Instance-side agent log.
tail -n 200 /var/log/amazon/ssm/amazon-ssm-agent.log | grep -iE "session|ssmmessages|timeout"
dial tcp: i/o timeout reaching ssmmessages.* → network
path broken. SESSION_CONNECTION_TIMEOUT.
403 Forbidden on ssmmessages:OpenDataChannel → IAM (Step 2).
Step 5: Agent version layer
Entry: port forwarding or session feature returns NotSupported;
macOS instance cannot start sessions.
aws ssm describe-instance-information \
--filters Key=InstanceIds,Values=<i-id> \
--query 'InstanceInformationList[].AgentVersion' --output text
| Agent version |
Session Manager |
Port forwarding |
macOS session |
| < 2.3.68.0 |
Not supported |
Not supported |
Not supported |
| 2.3.68.0 – 2.3.x |
Supported |
Not supported |
Not supported |
| 3.0.196+ |
Supported |
Supported |
Not supported |
| 3.1.x+ |
Supported |
Supported |
Supported |
- Below 2.3.68 → sessions fail with
NotSupported or silently.
AGENT_OUTDATED.
- Below 3.0.196 → port forwarding returns
NotSupported.
AGENT_OUTDATED (port forwarding).
- macOS below 3.1 → session API errors. AGENT_OUTDATED (macOS).
Agent self-update requires reaching s3.*.amazonaws.com or an S3
VPC endpoint. A locked-down private subnet without an S3 endpoint
stays on the old agent.
Step 6: Session document layer
Entry: InvalidDocument, InvalidDocumentVersion, or document
schema errors on session start.
aws ssm get-document --name <document-name> --output json | jq '.'
aws ssm describe-document --name <document-name> --output json | jq '.'
- Document
Status: Failed or SchemaVersion not 1.0 for a
session document → document error. SESSION_DOCUMENT_ERROR.
- The default document
SSM-SessionManagerRunShell should have
DocumentType: Session. If DocumentType is Command or the
schema is wrong, sessions fail. SSM_DOCUMENT_ERROR.
- For a custom document, the schema must match the session document
schema (inputs for
s3BucketName, cloudWatchLogGroupName,
kmsKeyId, shellProfile). Missing fields default to no output.
- Document sharing: a session document must be shared with the
caller account if cross-account. Missing share →
AccessDeniedException on StartSession.
Step 7: Port forwarding layer
Entry: port forwarding command connects but the forwarded port
cannot reach the target.
Moved to references/diagnostic-commands.md.
start-session --document-name AWS-StartPortForwardingSession with portNumber/hostName parameters.
- Document name. The default port-forwarding document is
AWS-StartPortForwardingSession (managed). A custom document
must be Session type and use the port-forwarding schema.
- Target host reachability. The
hostName is resolved from
the INSTANCE, not the caller. If the instance cannot route to
hostName (different VPC, SG block), the forwarded port
connects to nothing. PORT_FORWARDING_FAILURE.
- Agent version. Port forwarding requires agent >= 3.0.196.
Below →
NotSupported. AGENT_OUTDATED.
Step 8: Shell profile layer
Entry: session opens and closes immediately; agent log shows
SessionTypeHandler errors.
# On the instance, tail the agent log
tail -n 200 /var/log/amazon/ssm/amazon-ssm-agent.log | grep -iE "SessionTypeHandler|shell|profile"
.bashrc with an exit / logout → session closes immediately.
SHELL_PROFILE_ERROR.
.bash_profile syntax error → session fails to spawn the shell.
SHELL_PROFILE_ERROR.
- Custom
shellProfile in the session document pointing to a
non-existent binary → session opens, exits.
SHELL_PROFILE_ERROR.
Step 9: Audit log / session output to S3 layer
Entry: sessions work but no JSON output in the S3 session bucket.
Moved to references/diagnostic-commands.md.
get-document s3BucketName/s3KeyPrefix, get-bucket-policy, head-bucket on the session-output bucket.
- Document
s3BucketName empty → no S3 output configured. Add the
bucket name in the document. AUDIT_LOG_S3_MISSING.
- Bucket policy missing the grant for
arn:aws:iam::<account>:role/<instance-role> s3:PutObject on
arn:aws:s3:::<bucket>/<prefix>/* → the agent writes but S3
rejects. AUDIT_LOG_S3_MISSING.
- Bucket Region vs document Region mismatch → the agent writes to
the wrong Region endpoint.
- SSE-KMS bucket where the role lacks
kms:GenerateDataKey → write
fails. SESSION_RECORDING_S3.
For session recording (shell scrollback), the same bucket and a
longer s3KeyPrefix apply. If scrollback is truncated, check the
document's cloudWatchLogGroupName (separate stream) and the
recording-enabled flag.
Step 10: CloudWatch Logs delivery layer
Entry: sessions work but the CloudWatch Logs group is empty.
Moved to references/diagnostic-commands.md.
get-document cloudWatchLogGroupName/cloudWatchStreamingEnabled, describe-log-groups, role logs:CreateLogStream/PutLogEvents simulation.
- Document
cloudWatchLogGroupName empty → no CW Logs output
configured. CLOUDWATCH_LOGS_MISSING.
- Role missing
logs:CreateLogStream / logs:PutLogEvents → agent
cannot write. CLOUDWATCH_LOGS_MISSING.
- Log group in a different account without resource-policy grant
to the SSM service → writes denied.
Step 11: Patch baseline blocking layer
Entry: sessions fail during a maintenance window; ScanOnly or
Install association in Running state.
Moved to references/diagnostic-commands.md.
describe-instance-associations-status and describe-association to detect a Running ScanOnly/Install association during the session failure window.
- Association
Status: Running during a patch window → agent busy;
session data channel may be slow to open. Rare; usually resolves
when the patch completes. PATCH_BASELINE_BLOCKING.
- If the association is
Failed, the patch itself errored; sessions
are unaffected. Different root cause.
Step 12: INSUFFICIENT_DATA — when none of the layers confirm
If every probe passes and no failing probe matches the symptom,
emit INSUFFICIENT_DATA. List the passing probes in EVIDENCE.
Recommend escalation to AWS Support with the instance id, session
id, and the failing probe outputs.
Output specification — diagnostic block
TARGET: <instance-id with session/document context>
VERDICT: ROOT_CAUSE_IDENTIFIED | INSUFFICIENT_DATA
REASON: <1-3 sentences naming the failed layer and the failing probe>
LAYER: <INSTANCE_NOT_REGISTERED | SESSION_CONNECTION_TIMEOUT |
AGENT_OUTDATED | IAM_PERMISSION_MISSING |
VPC_ENDPOINT_MISSING | SESSION_DOCUMENT_ERROR |
PORT_FORWARDING_FAILURE | SHELL_PROFILE_ERROR |
AUDIT_LOG_S3_MISSING | SESSION_RECORDING_S3 |
CLOUDWATCH_LOGS_MISSING | PATCH_BASELINE_BLOCKING |
SSM_DOCUMENT_ERROR | UNKNOWN>
EVIDENCE:
- <observed symptom — error string or behaviour>
- <failing probe — command and its output that confirms the cause>
- <passing probes — layers ruled out>
REMEDIATION:
1. <specific action with CLI command or API call>
2. <verification command after the fix>
Field rules:
TARGET includes the instance id and, when applicable, the
session document name and session id.
VERDICT is one of the two enumerated values.
EVIDENCE always includes (a) symptom, (b) failing probe output,
(c) at least one passing probe ruling out a competing layer.
Pre-flight safety checks (run before any state-changing CLI)
- MANDATORY CONFIRMATION GATE. Before any state-changing
operation (
start-session, terminate-session, put-document,
update-document, create-vpc-endpoint, attach-role-policy,
put-bucket-policy), emit and await operator approval.
- Read-only first. Every probe in the diagnostic tree is
read-only. Do not perform state-changing operations as probes.
terminate-session closes a live session the operator may be
using. Confirm before terminating; check describe-sessions --state Active first.
update-document on SSM-SessionManagerRunShell affects every
session using the default document. Use a custom document for
testing changes before applying to the default.
create-vpc-endpoint is billed hourly; confirm the endpoint
is needed before creating. The three SSM endpoints (~$0.01/hour
each in us-east-1) are cheap but accrue.
- Role policy changes affect every instance using that role.
Use a test role on a test instance before applying to production.
Remediation guidance
Moved to references/error-handling.md.
Per-layer fix CLIs: associate-iam-instance-profile + Core policy + agent start (INSTANCE_NOT_REGISTERED), ssmmessages inline policy (IAM), create-vpc-endpoint ssmmessages, SG egress + private DNS (TIMEOUT), agent update commands per OS, document reset (DOCUMENT), port-forwarding checks, shell profile fixes, S3 bucket policy + kms:GenerateDataKey, CloudWatch Logs config, patch-window reschedule.
Deep reference
Symptom → layer decision matrix
Moved to references/advanced-patterns.md.
12-row error-string/behaviour -> LAYER decision matrix (instance absent, ConnectionLost, ChannelClosedException, AccessDeniedException caller vs agent log, NotSupported, InvalidDocument, instant close, empty bucket/logs, macOS).
Session document schema (SSM-SessionManagerRunShell)
Moved to references/session-output-and-document-reference.md.
Full JSON schema of the default session document: s3BucketName/s3KeyPrefix/s3EncryptionEnabled, cloudWatchLogGroupName/cloudWatchStreamingEnabled, kmsKeyId, runAs*, shellProfile; empty output fields disable audit paths.
Recent AWS features (2024-2026)
Moved to references/advanced-patterns.md.
CloudWatch streaming semantics, AWS-StartPortForwardingSessionToRemoteHost, macOS 3.1.x session support, scrollback recording, VPC endpoint resource policies.
References (load on demand)
- advanced-patterns — Mindset, Philosophy (control vs data plane), quick-start coverage rules, Step 0 non-obvious behaviours, symptom-to-layer decision matrix, Recent AWS features
- diagnostic-commands — pre-flight probes, the Step 2 caller-role probe, and the Step 7/9/10/11 per-layer probe commands moved from SKILL.md
- error-handling — per-layer remediation fix commands moved from SKILL.md
- session-output-and-document-reference — session document schema, audit-log bucket policies, CloudWatch Logs delivery, shell profiles, port-forwarding document variants
- vpc-endpoint-and-iam-reference — three-endpoint matrix, instance-role and caller-role permission maps, agent version support matrix
Domain
AWS CloudOps / Systems Manager Session Manager, Instance
Registration Diagnostics, VPC Endpoint Configuration, IAM Role
Permissions, Session Output and Audit Log Delivery, Port
Forwarding, and Shell Profile Management.
AWS documentation
1---2name: ssm-session-troubleshooter3description: 'Diagnoses AWS Systems Manager Session Manager failures through a thirteen-category diagnostic tree: managed instance not showing up (SSM Agent not running, activation code expired, hybrid enrollment), session connection timeout (ssmmessages endpoint, Security group egress), SSM Agent version outdated (session features require minimum agent version), IAM role missing ssm:StartSession / ssm:TerminateSession / ssm:ResumeSession (AmazonSSMManagedInstanceCore), VPC endpoint for SSM missing one of the three required endpoints (ssm, ec2messages, ssmmessages), session document errors (SSM_Session document schema or sharing), port forwarding failures (local-port-forwarding document and target-host reachability), shell profile errors (SSM-SessionManagerRunShell profile misconfig), audit log delivery to S3 missing (S3 bucket policy for session-output), session recording to S3 (encryption and bucket Region), CloudWatch Logs delivery missing (log group permission on the instance role), macOS vs Linux agent...'4license: Apache-2.05compatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). Offline symptom classification works from pasted error messages and instance configuration. Live-account diagnosis uses aws ssm describe-instance-information, describe-sessions, get-document, describe-instance-properties, aws ec2 describe-instances / describe-vpc-endpoints / describe-security-groups, aws iam simulate-principal-policy on the instance role, aws logs describe-log-groups / filter-log-events, aws...6metadata:7 source: https://skillmd.com/skills/jhkchan/ssm-session-troubleshooter8 domain: aws-cloudops9 complexity: high10 requires_llm: 'true'11 phase: '2'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: Management15 task_type: troubleshoot16 skill_class: capability17 lifecycle_status: active18 verdict_shape: ROOT_CAUSE_IDENTIFIED | INSUFFICIENT_DATA19 when_to_use: Diagnosing an SSM Session Manager failure (managed instance not showing in the console, session connection timeout, port forwarding failure, "is not registered to the account or role" error, missing audit logs in S3, missing CloudWatch Logs, session recording failure, shell profile error, patch-baseline-blocked session, SSM Document error, agent version too old for session features), walking a symptom to the failed layer with verify and fix commands, validating why a session cannot start or connect, or triaging a "Session Manager is broken" page where the root cause may be agent, IAM role, VPC endpoint, document, shell profile, or audit-log config — not necessarily the SSM service itself.20 when_not_to_use: SSM Run Command / Automation execution debugging (use ssm-automation-deployer or a run-command skill), EC2 instance reachability at the OS level (use ec2-instance-reachability checks), patch compliance posture audits (use ssm-patch-compliance-automator), or IAM policy authoring for the instance role (use iam-least-privilege-advisor). This skill diagnoses Session Manager connectivity and session-output failures; it does not audit patch baseline posture or debug Run Command document execution.21 activation_triggers: SSM Session Manager connection failed, SSM session timeout, managed instance not showing up, instance not registered SSM, SSM Agent not running, ssm:StartSession denied, SSM port forwarding failed, channel closed Session Manager, ssmmessages endpoint, VPC endpoint SSM missing, SSM session recording S3, SSM audit logs missing, SessionManagerRunShell, SSM Document error, SSM agent version outdated, hybrid activation expired, patch baseline blocking session, troubleshoot SSM Session Manager22 invocation_schema: 'Input: either (a) a symptom description (error message, observed behaviour, "session times out after 10s", "instance not in the console"), optionally paired with the instance configuration (describe-instance-information output) and recent SSM / CloudWatch logs, OR (b) an InstanceId plus session context (document name, session id, target host for port forwarding, VPC endpoint config) for live-account diagnosis. Output: a deterministic TARGET/VERDICT/REASON/LAYER/EVIDENCE/REMEDIATION block where VERDICT ∈ {ROOT_CAUSE_IDENTIFIED, INSUFFICIENT_DATA} and LAYER ∈ {INSTANCE_NOT_REGISTERED, SESSION_CONNECTION_TIMEOUT, AGENT_OUTDATED, IAM_PERMISSION_MISSING, VPC_ENDPOINT_MISSING, SESSION_DOCUMENT_ERROR, PORT_FORWARDING_FAILURE, SHELL_PROFILE_ERROR, AUDIT_LOG_S3_MISSING, SESSION_RECORDING_S3, CLOUDWATCH_LOGS_MISSING, PATCH_BASELINE_BLOCKING, SSM_DOCUMENT_ERROR, UNKNOWN}.'23 invocation_example: '# Minimal valid input (offline symptom classification):2425 Symptom: "EC2 instance i-0abcdef1234567890 in a private subnet does2627 not appear in the SSM Fleet Manager console. The instance2829 has the AmazonSSMManagedInstanceCore role attached but is3031 in a VPC with no ssmmessages VPC endpoint. Sessions started3233 from other instances in a public subnet work fine."3435 InstanceId: i-0abcdef12345678903637 VPC: vpc-priv (no internet gateway, no NAT gateway)3839 InstanceRole: EC2-SSM-Role (AmazonSSMManagedInstanceCore attached)4041 VPC endpoints configured: ssm (interface), ec2messages (interface)4243 VPC endpoints MISSING: ssmmessages4445 Last log line: "Session Manager connection timed out"'46 version: 0.1.047 author: Jacky Chan — AWS Community Builder48 keywords: SSM, Session Manager, ssm:StartSession, SSM Agent, AmazonSSMManagedInstanceCore, VPC endpoint, ssmmessages, ec2messages, port forwarding, shell profile, session recording, S3 audit logs, CloudWatch Logs, hybrid enrollment, activation code, patch baseline, SSM Document, troubleshooting49 tags: ssm, management, troubleshooting, session-manager, vpc-endpoint, iam-role, port-forwarding, session-recording, audit-logs50---5152# SSM Session Troubleshooter5354## Quick start5556- **Symptom → layer map (first plausible match drives the first probe):**57 instance not in Fleet Manager console → INSTANCE_NOT_REGISTERED58 / AGENT_OUTDATED; session times out after starting →59 SESSION_CONNECTION_TIMEOUT / VPC_ENDPOINT_MISSING;60 `AccessDeniedException` on StartSession → IAM_PERMISSION_MISSING;61 port forwarding fails to connect → PORT_FORWARDING_FAILURE /62 SESSION_CONNECTION_TIMEOUT; `ChannelClosedException` /63 shell-profile errors → SHELL_PROFILE_ERROR; session output not64 in S3 → AUDIT_LOG_S3_MISSING / SESSION_RECORDING_S3; CloudWatch65 Logs missing → CLOUDWATCH_LOGS_MISSING; session fails during66 maintenance window → PATCH_BASELINE_BLOCKING; document schema67 error → SESSION_DOCUMENT_ERROR / SSM_DOCUMENT_ERROR.68> Moved to [references/advanced-patterns.md](references/advanced-patterns.md#quick-start--verification-and-coverage-rules).69> Probe-driven verdicts, the three-endpoint rule for private subnets (missing ssmmessages = session timeouts), AmazonSSMManagedInstanceCore ssmmessages actions, agent version gates (2.3.68.0 sessions / 3.0.196 port-forwarding / 3.1.x macOS).7071## Mindset7273> Moved to [references/advanced-patterns.md](references/advanced-patterns.md#mindset).74> SSM service is usually innocent: the broken layer is agent, instance-role IAM, one of the three VPC endpoints, the session document, the shell profile, or the audit-log bucket policy. Start with describe-instance-information, describe-vpc-endpoints, and simulate-principal-policy.7576## Philosophy7778> Moved to [references/advanced-patterns.md](references/advanced-patterns.md#philosophy).79> Control plane (ssm) vs data plane (ssmmessages) vs ec2messages; registration != session-ready; role gates StartSession AND ssmmessages data channel; session output configured at the document level, not the instance level.8081## Quick reference — symptom triage table8283| Symptom phrase / error | Most likely layer | First probe |84|---|---|---|85| Instance absent from Fleet Manager / `describe-instance-information` returns empty | INSTANCE_NOT_REGISTERED | `describe-instance-information`, EC2 userdata / agent install log |86| Instance `PingStatus: ConnectionLost` / `InActive` | INSTANCE_NOT_REGISTERED / AGENT_OUTDATED | `describe-instance-information` AgentVersion, LastPingDateTime |87| Session starts on client, then "Connection timed out" / `ChannelClosedException` | SESSION_CONNECTION_TIMEOUT / VPC_ENDPOINT_MISSING | `describe-vpc-endpoints` for ssm/ec2messages/ssmmessages; SG egress to endpoints |88| `AccessDeniedException` on `start-session` CLI call (caller side) | IAM_PERMISSION_MISSING (caller) | `iam simulate-principal-policy` on the caller's role for `ssm:StartSession` |89| Session starts, agent log shows `ssmmessages:OpenDataChannel AccessDenied` | IAM_PERMISSION_MISSING (instance role) | `iam simulate-principal-policy` on the instance role for `ssmmessages:OpenDataChannel` |90| Port forwarding connects but target host unreachable | PORT_FORWARDING_FAILURE | `ssm start-session` document name, target host reachability from the instance |91| Port forwarding fails with `NotSupported` on the agent | AGENT_OUTDATED | `describe-instance-information` AgentVersion < 3.0.196 |92| `InvalidDocument` or `InvalidDocumentVersion` on session start | SESSION_DOCUMENT_ERROR / SSM_DOCUMENT_ERROR | `ssm get-document --name SSM-SessionManagerRunShell` |93| Session opens, exits immediately, `amazon-ssm-agent.log` shows shell profile error | SHELL_PROFILE_ERROR | agent log for `SessionTypeHandler` / profile errors |94| Sessions work but no JSON output in the S3 session bucket | AUDIT_LOG_S3_MISSING | `get-document` S3 bucket, `get-bucket-policy` for ssm-output grant |95| Session recording missing from S3; shell scrollback truncated | SESSION_RECORDING_S3 | document `s3BucketName`, KMS key policy, bucket Region |96| Sessions work but CloudWatch Logs group is empty | CLOUDWATCH_LOGS_MISSING | document `cloudWatchLogGroupName`, role `logs:CreateLogStream` |97| Sessions fail during a maintenance window; `ScanOnly` association in `Running` state | PATCH_BASELINE_BLOCKING | `describe-association`, `describe-instance-associations-status` |98| macOS instance cannot start session; agent installed but session API errors | AGENT_OUTDATED | AgentVersion < 3.1.x for macOS session support |99| None of the above; region-wide SSM event | INSUFFICIENT_DATA | `aws health describe-events`, AWS Service Health Dashboard |100101## Pre-flight: instance and session state102103Gather the canonical configuration and short-circuit on instance104states that mimic session failures. Misclassifying these produces105hours of session debugging for a problem that is not a session106problem.107108> Moved to [references/diagnostic-commands.md](references/diagnostic-commands.md#pre-flight-probes-instance-and-session-state).109> Eight probes: describe-instance-information / -properties, describe-sessions, get-document, instance-role simulate-principal-policy (ssm + ssmmessages + s3/logs actions), describe-vpc-endpoints, security-group egress, agent-log filter, AWS Health.110111### Instance-state short-circuit112113| `PingStatus` / `describe-instance-information` | Effect on diagnosis |114|---|---|115| `Online` + recent `LastPingDateTime` | Agent control channel works; if sessions fail, the issue is data channel, IAM, document, or network — not registration. |116| `ConnectionLost` / `InActive` | Agent stopped, instance stopped, or network break. The instance will not appear in Fleet Manager. Start at INSTANCE_NOT_REGISTERED. |117| Instance absent from `describe-instance-information` | Either the agent is not installed/running, the instance role lacks `ssm:UpdateInstanceInformation`, or the instance cannot reach `ssm.*.amazonaws.com`. Start at INSTANCE_NOT_REGISTERED. |118| `AgentVersion: 2.x.x` (below 2.3.68) | Session Manager not supported on this agent version. Sessions fail with `NotSupported` or silently. AGENT_OUTDATED. |119| `AgentVersion: 3.0.x` below 3.0.196 | Port forwarding not supported. PORT_FORWARDING_FAILURE due to AGENT_OUTDATED. |120| `PlatformName: Mac OS` + agent below 3.1.x | Session Manager not supported on macOS below 3.1. AGENT_OUTDATED. |121122If input is malformed (missing InstanceId, absent symptom123description, no document name for document errors), emit:124125```text126TARGET: <instance-id or unknown>127VERDICT: INSUFFICIENT_DATA128REASON: Input is missing required context — at minimum a symptom129 description (error string or observed behaviour) and the130 InstanceId, plus for document/output errors the session document131 name and the target S3 bucket or CloudWatch log group.132LAYER: UNKNOWN133EVIDENCE:134 - Missing: <list specific missing fields>135REMEDIATION: Re-prompt for: (1) the exact error string or observed136 symptom, (2) the InstanceId and platform (Linux / macOS /137 Windows), (3) the instance VPC and whether it has internet138 access, and (4) for output/audit errors, the session document139 name and the target S3 bucket / CloudWatch log group.140```141142## Process — Diagnostic decision tree (apply in symptom order)143144Symptom-driven. Pick the entry point based on the observed symptom,145then walk the layer-specific probes in order. **Never emit146ROOT_CAUSE_IDENTIFIED without a failing probe that matches the147symptom.**148149### Step 0: Non-obvious behaviours that change diagnosis150151> Moved to [references/advanced-patterns.md](references/advanced-patterns.md#step-0-non-obvious-behaviours-that-change-diagnosis).152> Three-endpoint rule, StartSession on the caller vs ssmmessages on the instance, AmazonEC2RoleforSSM deprecation, agent version floors and self-update via S3, document-carried audit config, shell-profile instant-close, hybrid activation expiry, patch associations slowing the data channel, macOS agent differences, stale Active sessions.153154### Step 1: Instance registration layer155156Entry: instance absent from Fleet Manager /157`describe-instance-information` returns empty for the instance.1581591. **Is the instance running and does it have an instance profile?**160 ```bash161 aws ec2 describe-instances --instance-ids <i-id> \162 --query 'Reservations[0].Instances[0].[State.Name,IamInstanceProfile.Arn]' --output text163 ```164 - State `stopped` → start the instance first.165 - No instance profile ARN → the role is missing; attach one.166 **INSTANCE_NOT_REGISTERED.**1671682. **Does the instance role include AmazonSSMManagedInstanceCore?**169 ```bash170 aws iam list-attached-role-policies --role-name <role-name> --output json171 ```172 - AmazonSSMManagedInstanceCore NOT attached → the agent cannot173 call `ssm:UpdateInstanceInformation`. **INSTANCE_NOT_REGISTERED.**174 - Legacy `AmazonEC2RoleforSSM` → deprecated; switch to175 AmazonSSMManagedInstanceCore.1761773. **Can the agent reach the SSM endpoint?**178 - Public subnet: route to IGW; agent reaches `ssm.<region>.amazonaws.com`.179 - Private subnet with NAT: route to NAT; agent reaches the180 public SSM endpoint.181 - Private subnet without NAT: needs `ssm`, `ec2messages`, and182 `ssmmessages` interface VPC endpoints.183 - VPC endpoint missing → agent never registers.184 **INSTANCE_NOT_REGISTERED (network).**1851864. **Is the SSM Agent running on the instance?**187 On the instance:188 ```bash189 sudo systemctl status amazon-ssm-agent # Linux systemd190 sudo launchctl list | grep amazon-ssm-agent # macOS191 Get-Service AmazonSSMAgent # Windows PowerShell192 ```193 - Agent not installed or stopped → install or start it.194 **INSTANCE_NOT_REGISTERED.**1951965. **For hybrid (non-EC2) instances: is the activation valid?**197 ```bash198 aws ssm describe-activations --output json199 ```200 - `ExpiredDate` in the past or `RegistrationLimit` reached →201 the agent cannot re-register after a restart.202 **INSTANCE_NOT_REGISTERED (hybrid).**203204If the instance is running, the role is correct, the agent is205installed, but registration still fails, move to the VPC endpoint206layer (Step 5) — the agent may not be reaching `ssm.*`.207208### Step 2: IAM permission layer (instance role)209210Entry: session starts on the client then times out, or agent log211shows `ssmmessages:OpenDataChannel AccessDenied`.212213```bash214aws iam simulate-principal-policy \215 --policy-source-arn "<instance-role-arn>" \216 --action-names ssm:UpdateInstanceInformation \217 ssmmessages:CreateControlChannel ssmmessages:CreateDataChannel \218 ssmmessages:OpenControlChannel ssmmessages:OpenDataChannel \219 s3:PutObject logs:CreateLogStream \220 --output json221```222223- Any action that returns `implicitDeny` or `explicitDeny` confirms224 the role is missing the permission. **IAM_PERMISSION_MISSING.**225- `ssmmessages:OpenDataChannel` denied → session times out within226 seconds of starting on the client.227- `s3:PutObject` on the session-output bucket denied → sessions228 work but audit logs never land in S3. Cross-reference Step 7.229- `logs:CreateLogStream` denied → sessions work but CloudWatch230 Logs group stays empty. Cross-reference Step 9.231232For the caller's role (the human or service invoking StartSession):233> Moved to [references/diagnostic-commands.md](references/diagnostic-commands.md#step-2--caller-role-probe).234> simulate-principal-policy on the caller's role for ssm:StartSession / ssm:TerminateSession scoped to the instance and SSM-SessionManagerRunShell document ARNs.235- `ssm:StartSession` denied on the caller side → the CLI/API call236 returns `AccessDeniedException` immediately, before any session237 is attempted. **IAM_PERMISSION_MISSING (caller).**238239### Step 3: VPC endpoint layer240241Entry: instance `Online` (registered) but session times out;242private subnet with no internet egress.243244```bash245VPC_ID=$(aws ec2 describe-instances --instance-ids <i-id> \246 --query 'Reservations[0].Instances[0].VpcId' --output text)247aws ec2 describe-vpc-endpoints --filters Name=vpc-id,Values=$VPC_ID \248 --query 'VpcEndpoints[?contains(ServiceName,`ssm`)].[ServiceName,State,VpcEndpointType]' --output table249```250251Required endpoints (interface type) for private-subnet SSM:252253| Endpoint service | Required for |254|---|---|255| `com.amazonaws.<region>.ssm` | Control plane: registration, StartSession API |256| `com.amazonaws.<region>.ec2messages` | Run Command / Association delivery |257| `com.amazonaws.<region>.ssmmessages` | Session data channel (the actual terminal stream) |258259- Missing `ssmmessages` → session times out within seconds. The260 most common SSM session failure. **VPC_ENDPOINT_MISSING.**261- Missing `ssm` → instance never registers (cross-reference Step 1).262- Endpoint present but `State: Pending` / `Failed` → the endpoint263 is not yet usable; wait for `Available`.264265Also check the endpoint security group: the VPC endpoint's SG266must allow 443 inbound from the instance's subnet/eni. A VPC267endpoint with no inbound rule on 443 is unreachable from the268instance.269270### Step 4: Session connection timeout layer271272Entry: session starts, then times out; VPC endpoints all present273and IAM passes.2742751. **Security group egress on the instance.**276 ```bash277 aws ec2 describe-security-groups --group-ids <sg-id> \278 --query 'SecurityGroups[0].IpPermissionsEgress' --output json279 ```280 - No egress on 443 to the VPC endpoint CIDRs or the service281 ranges → the agent cannot reach `ssmmessages.*.amazonaws.com`.282 **SESSION_CONNECTION_TIMEOUT.**2832842. **DNS resolution for the endpoint.**285 - Interface VPC endpoints use private DNS by default. If private286 DNS is disabled, the instance resolves `ssmmessages.*` to the287 public IP and the session fails in a no-egress VPC.288 - Check `describe-vpc-endpoints` for `PrivateDnsEnabled: true`.2892903. **Instance-side agent log.**291 ```bash292 tail -n 200 /var/log/amazon/ssm/amazon-ssm-agent.log | grep -iE "session|ssmmessages|timeout"293 ```294 - `dial tcp: i/o timeout` reaching `ssmmessages.*` → network295 path broken. **SESSION_CONNECTION_TIMEOUT.**296 - `403 Forbidden` on `ssmmessages:OpenDataChannel` → IAM (Step 2).297298### Step 5: Agent version layer299300Entry: port forwarding or session feature returns `NotSupported`;301macOS instance cannot start sessions.302303```bash304aws ssm describe-instance-information \305 --filters Key=InstanceIds,Values=<i-id> \306 --query 'InstanceInformationList[].AgentVersion' --output text307```308309| Agent version | Session Manager | Port forwarding | macOS session |310|---|---|---|---|311| < 2.3.68.0 | Not supported | Not supported | Not supported |312| 2.3.68.0 – 2.3.x | Supported | Not supported | Not supported |313| 3.0.196+ | Supported | Supported | Not supported |314| 3.1.x+ | Supported | Supported | Supported |315316- Below 2.3.68 → sessions fail with `NotSupported` or silently.317 **AGENT_OUTDATED.**318- Below 3.0.196 → port forwarding returns `NotSupported`.319 **AGENT_OUTDATED (port forwarding).**320- macOS below 3.1 → session API errors. **AGENT_OUTDATED (macOS).**321322Agent self-update requires reaching `s3.*.amazonaws.com` or an S3323VPC endpoint. A locked-down private subnet without an S3 endpoint324stays on the old agent.325326### Step 6: Session document layer327328Entry: `InvalidDocument`, `InvalidDocumentVersion`, or document329schema errors on session start.330331```bash332aws ssm get-document --name <document-name> --output json | jq '.'333aws ssm describe-document --name <document-name> --output json | jq '.'334```335336- Document `Status: Failed` or `SchemaVersion` not `1.0` for a337 session document → document error. **SESSION_DOCUMENT_ERROR.**338- The default document `SSM-SessionManagerRunShell` should have339 `DocumentType: Session`. If `DocumentType` is `Command` or the340 schema is wrong, sessions fail. **SSM_DOCUMENT_ERROR.**341- For a custom document, the schema must match the session document342 schema (inputs for `s3BucketName`, `cloudWatchLogGroupName`,343 `kmsKeyId`, `shellProfile`). Missing fields default to no output.344- Document sharing: a session document must be shared with the345 caller account if cross-account. Missing share →346 `AccessDeniedException` on StartSession.347348### Step 7: Port forwarding layer349350Entry: port forwarding command connects but the forwarded port351cannot reach the target.352353> Moved to [references/diagnostic-commands.md](references/diagnostic-commands.md#step-7--port-forwarding-probe).354> start-session --document-name AWS-StartPortForwardingSession with portNumber/hostName parameters.3553561. **Document name.** The default port-forwarding document is357 `AWS-StartPortForwardingSession` (managed). A custom document358 must be `Session` type and use the port-forwarding schema.3592. **Target host reachability.** The `hostName` is resolved from360 the INSTANCE, not the caller. If the instance cannot route to361 `hostName` (different VPC, SG block), the forwarded port362 connects to nothing. **PORT_FORWARDING_FAILURE.**3633. **Agent version.** Port forwarding requires agent >= 3.0.196.364 Below → `NotSupported`. **AGENT_OUTDATED.**365366### Step 8: Shell profile layer367368Entry: session opens and closes immediately; agent log shows369`SessionTypeHandler` errors.370371```bash372# On the instance, tail the agent log373tail -n 200 /var/log/amazon/ssm/amazon-ssm-agent.log | grep -iE "SessionTypeHandler|shell|profile"374```375376- `.bashrc` with an `exit` / `logout` → session closes immediately.377 **SHELL_PROFILE_ERROR.**378- `.bash_profile` syntax error → session fails to spawn the shell.379 **SHELL_PROFILE_ERROR.**380- Custom `shellProfile` in the session document pointing to a381 non-existent binary → session opens, exits.382 **SHELL_PROFILE_ERROR.**383384### Step 9: Audit log / session output to S3 layer385386Entry: sessions work but no JSON output in the S3 session bucket.387388> Moved to [references/diagnostic-commands.md](references/diagnostic-commands.md#step-9--audit-log--s3-output-probe).389> get-document s3BucketName/s3KeyPrefix, get-bucket-policy, head-bucket on the session-output bucket.390391- Document `s3BucketName` empty → no S3 output configured. Add the392 bucket name in the document. **AUDIT_LOG_S3_MISSING.**393- Bucket policy missing the grant for394 `arn:aws:iam::<account>:role/<instance-role>` `s3:PutObject` on395 `arn:aws:s3:::<bucket>/<prefix>/*` → the agent writes but S3396 rejects. **AUDIT_LOG_S3_MISSING.**397- Bucket Region vs document Region mismatch → the agent writes to398 the wrong Region endpoint.399- SSE-KMS bucket where the role lacks `kms:GenerateDataKey` → write400 fails. **SESSION_RECORDING_S3.**401402For session recording (shell scrollback), the same bucket and a403longer `s3KeyPrefix` apply. If scrollback is truncated, check the404document's `cloudWatchLogGroupName` (separate stream) and the405recording-enabled flag.406407### Step 10: CloudWatch Logs delivery layer408409Entry: sessions work but the CloudWatch Logs group is empty.410411> Moved to [references/diagnostic-commands.md](references/diagnostic-commands.md#step-10--cloudwatch-logs-delivery-probe).412> get-document cloudWatchLogGroupName/cloudWatchStreamingEnabled, describe-log-groups, role logs:CreateLogStream/PutLogEvents simulation.413414- Document `cloudWatchLogGroupName` empty → no CW Logs output415 configured. **CLOUDWATCH_LOGS_MISSING.**416- Role missing `logs:CreateLogStream` / `logs:PutLogEvents` → agent417 cannot write. **CLOUDWATCH_LOGS_MISSING.**418- Log group in a different account without resource-policy grant419 to the SSM service → writes denied.420421### Step 11: Patch baseline blocking layer422423Entry: sessions fail during a maintenance window; `ScanOnly` or424`Install` association in `Running` state.425426> Moved to [references/diagnostic-commands.md](references/diagnostic-commands.md#step-11--patch-baseline-association-probe).427> describe-instance-associations-status and describe-association to detect a Running ScanOnly/Install association during the session failure window.428429- Association `Status: Running` during a patch window → agent busy;430 session data channel may be slow to open. Rare; usually resolves431 when the patch completes. **PATCH_BASELINE_BLOCKING.**432- If the association is `Failed`, the patch itself errored; sessions433 are unaffected. Different root cause.434435### Step 12: INSUFFICIENT_DATA — when none of the layers confirm436437If every probe passes and no failing probe matches the symptom,438emit INSUFFICIENT_DATA. List the passing probes in EVIDENCE.439Recommend escalation to AWS Support with the instance id, session440id, and the failing probe outputs.441442## Output specification — diagnostic block443444```text445TARGET: <instance-id with session/document context>446VERDICT: ROOT_CAUSE_IDENTIFIED | INSUFFICIENT_DATA447REASON: <1-3 sentences naming the failed layer and the failing probe>448LAYER: <INSTANCE_NOT_REGISTERED | SESSION_CONNECTION_TIMEOUT |449 AGENT_OUTDATED | IAM_PERMISSION_MISSING |450 VPC_ENDPOINT_MISSING | SESSION_DOCUMENT_ERROR |451 PORT_FORWARDING_FAILURE | SHELL_PROFILE_ERROR |452 AUDIT_LOG_S3_MISSING | SESSION_RECORDING_S3 |453 CLOUDWATCH_LOGS_MISSING | PATCH_BASELINE_BLOCKING |454 SSM_DOCUMENT_ERROR | UNKNOWN>455EVIDENCE:456 - <observed symptom — error string or behaviour>457 - <failing probe — command and its output that confirms the cause>458 - <passing probes — layers ruled out>459REMEDIATION:460 1. <specific action with CLI command or API call>461 2. <verification command after the fix>462```463464Field rules:465466- `TARGET` includes the instance id and, when applicable, the467 session document name and session id.468- `VERDICT` is one of the two enumerated values.469- `EVIDENCE` always includes (a) symptom, (b) failing probe output,470 (c) at least one passing probe ruling out a competing layer.471472## Pre-flight safety checks (run before any state-changing CLI)473474- **MANDATORY CONFIRMATION GATE.** Before any state-changing475 operation (`start-session`, `terminate-session`, `put-document`,476 `update-document`, `create-vpc-endpoint`, `attach-role-policy`,477 `put-bucket-policy`), emit and await operator approval.478- **Read-only first.** Every probe in the diagnostic tree is479 read-only. Do not perform state-changing operations as probes.480- **`terminate-session`** closes a live session the operator may be481 using. Confirm before terminating; check `describe-sessions482 --state Active` first.483- **`update-document` on SSM-SessionManagerRunShell** affects every484 session using the default document. Use a custom document for485 testing changes before applying to the default.486- **`create-vpc-endpoint`** is billed hourly; confirm the endpoint487 is needed before creating. The three SSM endpoints (~$0.01/hour488 each in us-east-1) are cheap but accrue.489- **Role policy changes** affect every instance using that role.490 Use a test role on a test instance before applying to production.491492## Remediation guidance493494> Moved to [references/error-handling.md](references/error-handling.md#remediation-guidance).495> Per-layer fix CLIs: associate-iam-instance-profile + Core policy + agent start (INSTANCE_NOT_REGISTERED), ssmmessages inline policy (IAM), create-vpc-endpoint ssmmessages, SG egress + private DNS (TIMEOUT), agent update commands per OS, document reset (DOCUMENT), port-forwarding checks, shell profile fixes, S3 bucket policy + kms:GenerateDataKey, CloudWatch Logs config, patch-window reschedule.496497## Deep reference498499### Symptom → layer decision matrix500501> Moved to [references/advanced-patterns.md](references/advanced-patterns.md#symptom--layer-decision-matrix).502> 12-row error-string/behaviour -> LAYER decision matrix (instance absent, ConnectionLost, ChannelClosedException, AccessDeniedException caller vs agent log, NotSupported, InvalidDocument, instant close, empty bucket/logs, macOS).503504### Session document schema (SSM-SessionManagerRunShell)505506> Moved to [references/session-output-and-document-reference.md](references/session-output-and-document-reference.md#session-document-schema-ssm-sessionmanagerrunshell).507> Full JSON schema of the default session document: s3BucketName/s3KeyPrefix/s3EncryptionEnabled, cloudWatchLogGroupName/cloudWatchStreamingEnabled, kmsKeyId, runAs*, shellProfile; empty output fields disable audit paths.508509## Recent AWS features (2024-2026)510511> Moved to [references/advanced-patterns.md](references/advanced-patterns.md#recent-aws-features-2024-2026).512> CloudWatch streaming semantics, AWS-StartPortForwardingSessionToRemoteHost, macOS 3.1.x session support, scrollback recording, VPC endpoint resource policies.513514## References (load on demand)515516- [advanced-patterns](references/advanced-patterns.md) — Mindset, Philosophy (control vs data plane), quick-start coverage rules, Step 0 non-obvious behaviours, symptom-to-layer decision matrix, Recent AWS features517- [diagnostic-commands](references/diagnostic-commands.md) — pre-flight probes, the Step 2 caller-role probe, and the Step 7/9/10/11 per-layer probe commands moved from SKILL.md518- [error-handling](references/error-handling.md) — per-layer remediation fix commands moved from SKILL.md519- [session-output-and-document-reference](references/session-output-and-document-reference.md) — session document schema, audit-log bucket policies, CloudWatch Logs delivery, shell profiles, port-forwarding document variants520- [vpc-endpoint-and-iam-reference](references/vpc-endpoint-and-iam-reference.md) — three-endpoint matrix, instance-role and caller-role permission maps, agent version support matrix521522## Domain523524AWS CloudOps / Systems Manager Session Manager, Instance525Registration Diagnostics, VPC Endpoint Configuration, IAM Role526Permissions, Session Output and Audit Log Delivery, Port527Forwarding, and Shell Profile Management.528529## AWS documentation530531- **AWS Systems Manager Session Manager** — https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager.html532- **Setting up Session Manager** — https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-getting-started.html533- **Working with Session Manager** — https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-sessions.html534- **Troubleshooting Session Manager** — https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-troubleshooting.html535- **VPC endpoints for Systems Manager** — https://docs.aws.amazon.com/systems-manager/latest/userguide/setup-create-vpc.html536- **AmazonSSMManagedInstanceCore policy** — https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonSSMManagedInstanceCore.html537- **SSM Agent version history** — https://docs.aws.amazon.com/systems-manager/latest/userguide/ssm-agent.html538- **Session Manager auditing** — https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-auditing.html539- **Port forwarding with Session Manager** — https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-sessions-port-forwarding.html540- **AWS Health** — https://docs.aws.amazon.com/health/latest/ug/