{"id":8464,"date":"2021-05-21T05:19:50","date_gmt":"2021-05-21T05:19:50","guid":{"rendered":"https:\/\/blog.cloudthat.com\/?p=8464"},"modified":"2024-06-25T11:07:59","modified_gmt":"2024-06-25T11:07:59","slug":"runnung-commands-using-aws-systems-manager-a-step-by-step-guide","status":"publish","type":"blog","link":"https:\/\/www.cloudthat.com\/resources\/blog\/running-commands-using-aws-systems-manager-a-step-by-step-guide","title":{"rendered":"Running Commands Using AWS Systems Manager: A Step-by-Step Guide"},"content":{"rendered":"<p>AWS Systems Manager (formerly known as AWS SSM) is an AWS service used to view and control AWS infrastructure. It provides a solution to automate the operational tasks for Amazon instances. It lets engineers manage the configuration of the managed instances remotely and securely. AWS System Manager is an AWS service that helps in maintaining the servers. You can automate the process and perform desired tasks on the servers without logging into the system.<\/p>\n<p>Having several servers seems to be a great way for efficient utilization. But the maintenance of the servers can be tedious enough to put a huge overall cost. The engineers must log in to the machines, list the patches, select, and install the same. This sounds to be easy, but it becomes cumbersome when a bunch of machines must be maintained. It would take more time and is a manual task affecting the performance. Additionally, this may also cause manual errors like, missing instances, missing packages during the process and creating issues.<\/p>\n<p>The AWS Systems Manager is a powerful tool with varied capabilities categorized into operational management, application management, change management, node management, shared resources.<br \/>\nToday we will focus on the \u2018Run Command\u2019 targeted to simplify operational management tasks.<\/p>\n<h2><strong>Run Command:\u00a0<\/strong><\/h2>\n<p>It is a capability of the AWS Systems manager that allows you to remotely maintain and manage the servers. Managed servers are servers that have been configured for use by SSM service.<\/p>\n<p>With Run Command, we can perform:<\/p>\n<ul>\n<li>Adhoc exceptions. and<\/li>\n<li>one-time configuration changes<\/li>\n<\/ul>\n<p>Follow the guide below for a demo on how to use the Run command.<\/p>\n<h2><strong>Prerequisites:\u00a0<\/strong><\/h2>\n<p>You will need an AWS Account to begin with. If you are new to AWS or do not have an account, you can create one using this link:<\/p>\n<p><a href=\"https:\/\/aws.amazon.com\/free\/\">https:\/\/aws.amazon.com\/free\/<\/a><\/p>\n<p><strong>Here is a step-by-step guide to use the run command:\u00a0\u00a0<\/strong><\/p>\n<h2><strong>\u00a0Create an IAM role for EC2-SSM:\u00a0<\/strong><\/h2>\n<ol>\n<li>Go to IAM Dashboard in AWS Console<br \/>\n<a href=\"https:\/\/console.aws.amazon.com\/iam\/home?region=us-east-2\" target=\"_blank\" rel=\"noopener\">https:\/\/console.aws.amazon.com\/iam\/home?region=us-east-2\u00a0\u00a0<\/a><br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8465\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS1.png\" alt=\"IAM Dashboard\" width=\"628\" height=\"258\" \/><br \/>\n<\/a><\/li>\n<li>Click on <strong>Roles<\/strong> on the left pane and click <strong>Create role<br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8466\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS2.png\" alt=\"Create Role\" width=\"626\" height=\"253\" \/><br \/>\n<\/a><br \/>\n<\/strong><\/li>\n<li>Choose the AWS Service (EC2) and click next permissions<br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8467\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS3.png\" alt=\"Create Role\" width=\"498\" height=\"258\" \/><br \/>\n<\/a><\/li>\n<li>Choose <a href=\"https:\/\/console.aws.amazon.com\/iam\/home?region=us-east-2#\/policies\/arn%3Aaws%3Aiam%3A%3Aaws%3Apolicy%2FAmazonSSMFullAccess\">AmazonSSMFullAccess<\/a> and click on next<br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8468\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS4.png\" alt=\"Amazon SSMFullAccess\" width=\"495\" height=\"244\" \/><br \/>\n<\/a><\/li>\n<li>Give a name for the role and Click Create role<br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8469\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS5.png\" alt=\"Create Role\" width=\"626\" height=\"338\" \/><br \/>\n<\/a><\/li>\n<\/ol>\n<h2><strong>Create Instances with the above roles attached:<\/strong><\/h2>\n<ol>\n<li>Go to EC2 Dashboard in AWS<\/li>\n<li>Click on Launch Instance, Choose the ubuntu AMI (ami-0b9064170e32bde34)<\/li>\n<li>In Instance type, choose T2.micro and click on next<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8470\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS6.png\" alt=\"ubuntu AMI \" width=\"626\" height=\"252\" \/><br \/>\n<\/a><\/li>\n<li>In Instance Configure, let the instance count by 1.In the IAM role, choose the role you created in the previous task<br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8471\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS7.png\" alt=\"IAM role\" width=\"626\" height=\"362\" \/><br \/>\n<\/a><\/li>\n<li>Keep default values for storage and move to the next stage.<\/li>\n<li>Add tags to the Instance<br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8472\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS8.png\" alt=\"Adding Tags\" width=\"626\" height=\"224\" \/><br \/>\n<\/a><\/li>\n<li>Review and Create the instance.<\/li>\n<\/ol>\n<h2><strong>Create a VPC Endpoint:\u00a0<\/strong><\/h2>\n<ol>\n<li>Go to VPC Console,<\/li>\n<li>Choose Endpoints towards the left pane<br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8473\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS9.png\" alt=\"Endpoints\" width=\"178\" height=\"238\" \/><br \/>\n<\/a><\/li>\n<li>Click on Create Endpoint<br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8474\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS10.png\" alt=\"Creating Endpoint\" width=\"396\" height=\"73\" \/><\/a><\/li>\n<li>Choose Service Category: AWS Service and select the Service<a href=\"http:\/\/com.amazonaws.us-east-2.ssm\" target=\"_blank\" rel=\"noopener\">com.a<br \/>\nmazonaws.us-east-2.ssm<\/a><br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWSnew.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8478\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWSnew.png\" alt=\"AWS Services\" width=\"513\" height=\"72\" \/><\/a><br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS11.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8475\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS11.png\" alt=\"Service Category\" width=\"626\" height=\"137\" \/><br \/>\n<\/a><\/li>\n<li>Choose the VPC, subnet to which you want to create an endpoint<\/li>\n<li>Click on create Endpoint<br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS12.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8479\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS12.png\" alt=\"AWS Service\" width=\"626\" height=\"232\" \/><\/a><br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS13.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8480\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS13.png\" alt=\"Create Endpoint\" width=\"411\" height=\"102\" \/><br \/>\n<\/a><\/li>\n<\/ol>\n<h2><strong>Create a run command and execute the command:<\/strong><\/h2>\n<ol>\n<li>Go to System manager console<\/li>\n<li>Towards the left pane, choose the Run Command Service<br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS14.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8481\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS14.png\" alt=\"Run Command\" width=\"213\" height=\"303\" \/><br \/>\n<\/a><\/li>\n<li>Click on the Run command<br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS15.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8482\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS15.png\" alt=\"Run Command\" width=\"626\" height=\"182\" \/><br \/>\n<\/a><\/li>\n<li>Choose the Command Document that is compatible with the type of end servers ( Linux \/ windows)In this demo,\u00a0 We are using Linux servers, so I choose\u00a0<a href=\"https:\/\/us-east-2.console.aws.amazon.com\/systems-manager\/documents\/AWS-ConfigureAWSPackage\/description?region=us-east-2\">AWS-ConfigureAWSPackage<\/a><a href=\"https:\/\/us-east-2.console.aws.amazon.com\/systems-manager\/documents\/AWS-ConfigureAWSPackage\/description?region=us-east-2\"><br \/>\n<\/a><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS16.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8483\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS16.png\" alt=\"AWS-Configure-AWSPackage\" width=\"626\" height=\"308\" \/><\/a>&nbsp;<\/li>\n<li>Scroll down, in command parameters,<br \/>\na. Action, (install)<br \/>\nb. Installation type:<br \/>\nc. Name: Provide the valid Package name ( eg: AmazonCloudWatchAgent, AwsEnaNetworkDriver)<br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS17.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8484\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS17.png\" alt=\"AWS-Configure AWS PAckage\" width=\"604\" height=\"369\" \/><br \/>\n<\/a><\/li>\n<li>Targets: there are 3 ways you can identify the end servers:<br \/>\na. By specifying tags<br \/>\nb. Manually choosing<br \/>\nc. Choosing the resource GroupClick on Choose instance manually<br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS18.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8485\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS18.png\" alt=\"Choose instance manually\" width=\"609\" height=\"275\" \/><br \/>\n<\/a><\/li>\n<li>In the output options, Uncheck, enable S3 output<br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS19.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8486\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS19.png\" alt=\"S3 bucket\" width=\"626\" height=\"150\" \/><br \/>\n<\/a><\/li>\n<li>Click on the run command.<br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS20.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8487\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS20.png\" alt=\"Run command\" width=\"331\" height=\"109\" \/><br \/>\n<\/a>You will notice the execution of the command.<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS21.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8488\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS21.png\" alt=\"Execution of command\" width=\"626\" height=\"313\" \/><\/a><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8489\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS22.png\" alt=\"Run Command\" width=\"626\" height=\"281\" \/><br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS23.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8491\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS23.png\" alt=\"Run Command\" width=\"626\" height=\"129\" \/><\/a><br \/>\n<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS24.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8490\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/AWS24.png\" alt=\"Run command\" width=\"626\" height=\"181\" \/><br \/>\n<\/a><\/li>\n<li><strong>Verify:<br \/>\n<\/strong><\/p>\n<pre class=\"lang:default decode:true \">sudo systemctl start amazon-cloudwatch-agent\r\nsudo systemctl status amazon-cloudwatch-agent<\/pre>\n<\/li>\n<\/ol>\n<p>Hope this blog has shed light on the uses of \u2018run command\u2019, and how it can be used to manage and maintain the servers. It can be used to perform patch updates\u00a0to the servers without SSH into the machine easily and securely.<br \/>\nTo learn more about <strong>managing infrastructure on AWS<\/strong>, then here is a <a href=\"https:\/\/blog.cloudthat.com\/manage-infrastructure-on-aws-using-terraform-cloud-for-free\/?utm_source=blog-website&amp;utm-medium=text-link&amp;utm_campaign=manage-infrastructure-on-aws-using-terraform-cloud-for-free\/\" target=\"_blank\" rel=\"noopener\"><strong>step-by-step guide<\/strong><\/a> for you.<\/p>\n<p>Feel free to drop any queries and our team of experts will get back to you very soon.<\/p>\n<p>Cheers!<\/p>\n","protected":false},"author":234,"featured_media":8509,"parent":0,"comment_status":"open","ping_status":"open","template":"","blog_category":[3606,3607],"user_email":"shylaj@cloudthat.com","published_by":"324","primary-authors":"","secondary-authors":"","acf":[],"_links":{"self":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/8464"}],"collection":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/users\/234"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/comments?post=8464"}],"version-history":[{"count":1,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/8464\/revisions"}],"predecessor-version":[{"id":46231,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/8464\/revisions\/46231"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/media?parent=8464"}],"wp:term":[{"taxonomy":"blog_category","embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog_category?post=8464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}