SSM SessionManager Helper is a tool that helps configure SSM Session Manager port-forwarded sessions. The SSM SessionManager Helper simplifies the connection process by allowing you to select the account, region and instance to connect to without having to navigate to the AWS Web console to find the instance id.
The Session Helper leverages the AWS CLI, boto3 and the AWS Session Manager Plugin to create a port-forwarded tunnel through SSM Session Manager to your local machine.
- Python 3.6 or later
- AWS CLI
- AWS Session Manager plugin
- Call
pip install -r requirements.txt
-
Call
python configurator.py -
Select an active profile
-
From the configurator dialog, select the desired profile, region and instance by clicking on the appropriate field
-
Specify the remote port and local port for the connection
-
Click
Connect -
Confirm the connection details
-
The SSM SessionManager Helper will close and call start an ssm session with the provided details
aws ssm start-sessionwill be called to initialize a sessionWaiting for connectionswill appear when the session is created
This script will make the following boto3 calls:
- ssm start_session
- ec2 describe_instances
The role that is assumed by the user of this script must be configured to allow the above boto3 calls to execute.
A permissive policy that permits the necessary actions for the above boto3 calls would be as follows (it is very important that when implementing this in your account, do NOT use '*' resources in your policies):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:StartSession"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"ssm:DescribeSessions",
"ssm:GetConnectionStatus",
"ssm:DescribeInstanceProperties",
"ec2:DescribeSecurityGroups",
"ec2:DescribeInstances"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"kms:GenerateDataKey"
],
"Resource": "*"
}
]
}
More details on restricting access to SSM by resource and tag values can be found in the SSM Systems Manager documentation.
- SSM SessionManager Helper: How It Works - a deeper dive into how this script works
- SSM SessionManager Helper: Future Enhancements - a list of how this script can be enhanced in the future
- Sample IAM policies for Session Manager - official AWS documentation about restricting user access to SSM resources
- Port Forwarding Using AWS System Manager Session Manager - a blog post about how port forwarding works with AWS Session Manager
- Python Prompt Toolkit 3.0 - the toolkit used to implement the UI for the SSM SessionManager Helper




