AWS Session Manager Step by Step Tutorial¶
- You can find the source code for this video in my GitHub Repo.
Prerequisites¶
- AWS account (AWS Free Tier Sign Up)
- AWS CLI (Installation guide)
Create IAM Role and EC2 Instance¶
- Create
SSMFullAccess
IAM role and attachAmazonSSMFullAccess
managed policy to it. - Create EC2 instance and attach
SSMFullAccess
instance profile. - Verify that EC2 instance was registered in AWS Session Manager console.
Create CloudWatch Log Group¶
- Create
ssm-session
CloudWatch log group. - Update Session Manager settings to use
ssm-session
log group.
Install AWS Session Manager Plugin.¶
- Follow instructions for your OS here.
Create IAM Policy and IAM user¶
- Create
UserStartSessionPolicy
IAM Policy with the following content. Replace<region>
and<account-id>
.
- Create
SSMAccess
IAM group and attachUserStartSessionPolicy
policy. - Create
developer
user and put it toSSMAccess
group. - Run
aws configure
to create default profile.
SSH to EC2 Instance¶
-
To ssh to the EC2 instance use the following command, replace
<ec2-instace-id>
. -
Update EC2 tag labels.
-
Install nginx on EC2 instance.
Port Forward from EC2 to localhost¶
- To port forward from EC2 instance to localhost use the following command, replace
<ec2-instace-id>
.
aws ssm start-session \
--target <ec2-instace-id> \
--document-name AWS-StartPortForwardingSession \
--parameters '{"portNumber":["80"], "localPortNumber":["8080"]}'
Clean
- Delete
developer
IAM user - Delete
SSMAccess
IAM group - Delete
UserStartSessionPolicy
IAM policy - Delete
ssm-session
CloudWatch log group - Delete
ssm
Security Group