Skip to content

When I try to connect to EC2 with proper IAM role, the sessions manager gives error.

0

When I try to connect to EC2 with proper IAM role, the sessions manager gives error.

Document type: 'Command' is not supported. Only type: 'Session' is supported for session manager.

this seems to be a problem with the EC2 instances in only one account in my AWS organizations. Other instances in other accounts work fine.

asked a year ago196 views

3 Answers
0
Accepted Answer

I saw that there was one document with name "SSM-SessionManagerRunShel" created as Command by the team a year back. Once I removed it and started a session on the EC2, it started working.

answered a year ago

0

This error suggests that you're trying to use Session Manager with an incorrect document type. Session Manager only supports documents of type 'Session', but it appears you're attempting to use a document of type 'Command'.

To resolve this issue, check the following:

  1. Make sure you're using the correct approach to start a session. When connecting through the AWS console, simply select the instance, choose "Connect," and then select "Session Manager" as the connection method.

  2. If you're using the AWS CLI to connect, ensure you're using the correct command format. For Session Manager connections, use the start-session command rather than a Run Command operation.

  3. Verify that the IAM role attached to your EC2 instances has the proper permissions. The role should include the AmazonSSMManagedInstanceCore managed policy or equivalent permissions that specifically allow Session Manager operations.

  4. Ensure that the SSM Agent is installed and running on your EC2 instances. The agent must be version 2.3.68.0 or later to support Session Manager.

  5. Check if there are any custom Session Manager configurations in the problematic AWS account that might be causing this issue, since you mentioned it only happens in one specific account within your organization.

  6. If you're using a custom document for Session Manager, verify that it's properly configured as a Session type document.

Since this issue is isolated to one account in your AWS organization, it suggests there might be a configuration difference in that account compared to your other accounts. You might want to compare the Session Manager settings, IAM policies, and SSM Agent configurations between the accounts to identify the discrepancy.
Sources
Troubleshooting Session Manager - AWS Systems Manager
Unable to connect EC2 instance via Session Manager | AWS re:Post
Connect to your Amazon EC2 instance using Session Manager - Amazon Elastic Compute Cloud

answered a year ago

0

The error means Session Manager trying to use a document of type "Command" instead of the required "Session" type.

To fix it:

  • Ensure the default Session Manager document (AWS-StartSession) exists and is correct in the affected account.

  • Avoid using custom "Command" type documents for sessions.

  • Verify the IAM role has ssm:StartSession permission.

This usually resolves the issue when only one account is affected.

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.