As we all know AWS Systems Manager provides configuration management, which helps you maintain consistent configuration of your Amazon EC2 or on-premises instances. You can create a document in JSON or YAML format and perform the operations on the EC2 Instance. You can access the EC2 console without launching a session through Sessions Manager. You can configure a state manager association with the EC2 instance and periodically run a custom document on top of that.
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/0%2AS8G-AH4f3GbQFZHF.png?w=1200&ssl=1)
In this article, I will give a step-by-step walk-through of Systems Manager setup and executing document workflows on top of EC2 Instances.
1: Create an IAM Role for the EC2 Instance. It needs SSM permission to communicate for any automated operations from the Systems Manager Console.
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2AUYqlmVLDy86TTl5_Fs5SBg.png?w=1200&ssl=1)
Add the below permissions and give a name to the role as EC2RoleSSM
AmazonSSMManagedInstanceCore
AmazonEC2RoleforSSM
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2AJB5DTA_rWekKhytFrHz10w.png?w=1200&ssl=1)
Once the role is created, it will be listed as below
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2AJLm87htRyksx2_FCDLHMtg.png?w=1200&ssl=1)
Go to systems manager services, we will concentrate on the Node Management section. As of now, NO managed instances are available so the fleet manager is taking us to the Get Started Page. Once the Ec2 instance is configured we can able to see the instance as a managed instance.
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2Af58mOthmhAyDIJ9WGDqd4w.png?w=1200&ssl=1)
2. Launch an EC2 instance ( Redhat Linux Version ) and attach the EC2RoleSSM IAM Role.
NOTE: By default, Amazon Linux has the Agent installed, so for demonstration purposes I considered RHEL
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2A4SDwlwZwChSDtKokRXRP3Q.png?w=1200&ssl=1)
I logged into the EC2 instance using local the pem key through local git bash and switched to root for convenience purpose.
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2A4FgHxhxUY-nW4_QRjXYS2Q.png?w=1200&ssl=1)
Install wget and use wget to download the amazon-ssm-agent.rpm
Command to download the wget and SSM packages
1.yum install wget
2. wget https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm
3. yum install amazon-ssm-agent.rpm
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2AvnL1Bd5uj1Rk9CFr3tXYQA.png?w=1200&ssl=1)
Start/Enable/Status commands for SSM agent
systemctl enable amazon-ssm-agent
systemctl start amazon-ssm-agent
systemctl status amazon-ssm-agent
Start the SSM Agent to enable the connection between EC2 and the AWS Systems Manager.
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2A-oaQzFaLVv0T770QswUCUQ.png?w=1200&ssl=1)
Monitor the SSM logs using the below command
tail -f /var/log/amazon/ssm/amazon-ssm-agent.log
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2A-or7EOtG-a1Exb7OVKFC9w.png?w=1200&ssl=1)
Now we can see the instance available in Systems Manager => Fleet Manager section as shown below.
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2AIC5VDcMmahNt--hvV3wszA.png?w=1200&ssl=1)
Now EC2 Instances can be managed using AWS Systems Manager.
Let’s concentrate on the Run Command Functionality first from the below list of features.
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A611/1%2A-rL3k0S7l1-FQ_QXX5l_dw.png?w=1200&ssl=1)
As of now, docker is not installed in the machine. We will install using Run Command.
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2A4aZ1Bn1O8ul6QTo-0zJR8g.png?w=1200&ssl=1)
3: Click on Run Command è select platform type as linux and select Configure Docker as shown below.
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2ApOqifQxVSW_Yd7sHaDAhFQ.png?w=1200&ssl=1)
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2Aj4iSR3gWbceSnVf1QBbegQ.png?w=1200&ssl=1)
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2AL0bkXHYwUJWkrJb9r60ClQ.png?w=1200&ssl=1)
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2AWtJIsAvpCFTToKfjGNEP4Q.png?w=1200&ssl=1)
Click RUN
This will install the Docker in the EC2 Instance.
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2ARsjLGifP0B3gygi_iRxo6g.png?w=1200&ssl=1)
Once the Command is completed successfully, we can see the docker availability.
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2ACjG5aD0hY9BVmP-bWrIJ0g.png?w=1200&ssl=1)
Command status from console
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2A43ZHSrzQJi_g2349dFPGWQ.png?w=1200&ssl=1)
State Manager
Now we will use State Manager to uninstall docker from the RHEL EC2 Instance.
Click on Create an Association first
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2AMdi1jrib5TiRKR58nYNpKg.png?w=1200&ssl=1)
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2Aq0FfQTKW7jWA3kpYXi4_AQ.png?w=1200&ssl=1)
Select Uninstall from action choose the instance manually and the rest of the parameters as shown below and click on Create Association.
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2AxEgjke8TYojbZ8QGnNN0Gg.png?w=1200&ssl=1)
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2AMmM2Wg-9F4yu8r9Wr8C-Iw.png?w=1200&ssl=1)
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2AMMGlaMuUcH8dMOjklFgpOw.png?w=1200&ssl=1)
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2AwcqWl0_FQRqMnxkD0Ni3sw.png?w=1200&ssl=1)
Once document execution completed.
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2AWemSWqa7s-HiSwmGRqsy1g.png?w=1200&ssl=1)
Now we can check the docker status from cli
![](https://i0.wp.com/miro.medium.com/v2/resize%3Afit%3A875/1%2A3z_gRQQczXcyOtIkNGmiAQ.png?w=1200&ssl=1)
In this way, we can use AWS Systems Manager to execute custom documents, run automation, establish sessions, and configure parameter stores.
![Sarath Tamminana](https://i0.wp.com/enminto.com/wp-content/uploads/2021/05/Profile-Image-e1621598995164.jpg?resize=100%2C100&ssl=1)
The founder of TacoBIG.com.He is a Cloud Architect from Bangalore interested in contributing guidance to Cloud related communities. He loves to read books and share knowledge with others. He is keen on understanding Financial wisdom and sharing thoughts on how to achieve financial freedom.