How to Use AWS Systems Manager to Run Commands on EC2 Instances?

AWS provides a tool called AWS Systems Manager. Inside Systems Manager, there’s a feature called the Run command. This Run command helps us control things on our computers in the cloud. So, we’ll see how we can use AWS Systems Manager to tell our cloud computer to set up something called Nginx, which is like a tool to make websites work, on a special computer in the cloud called a Linux EC2 Instance.

Step 1:

Start by making sure that the AWS Systems Manager agent is up and running on your EC2 Instance. To do this, you can attach a special script that installs the agent when the instance is first started.

This agent is necessary for the EC2 Instance to talk to the AWS Systems Manager. Once this agent is set up correctly, you’ll notice that the instance appears as a managed instance when you look at the list of things in the AWS Systems Manager. This is like having your instance monitored and managed through AWS Systems Manager.

How to Use AWS Systems Manager to Run Commands on EC2 Instances?

Step 2:

 To run a command, go to the “Run Command” section and click on Run Command

How to Use AWS Systems Manager to Run Commands on EC2 Instances?

Step 3:

Next, we need to choose the type of document that needs to be run on the system

How to Use AWS Systems Manager to Run Commands on EC2 Instances?

For installing or running commands on a Linux-based system, we can use the AWS-RunShellScript document

Step 4:

Next, ensure to select your target Linux machine. This is where you want to run the command

How to Use AWS Systems Manager to Run Commands on EC2 Instances?

Step 5: 

Next, in the Command parameters, specify the commands that need to be run. So here we are installing nginx which is a web server on the Linux-based machine.

How to Use AWS Systems Manager to Run Commands on EC2 Instances?

Step 6:

You can then specify a timeout for the command and then run the command

How to Use AWS Systems Manager to Run Commands on EC2 Instances?

Once the Run command is sent, you will get the relevant notification

How to Use AWS Systems Manager to Run Commands on EC2 Instances?

Once the command has run successfully you will get a Success overall status

How to Use AWS Systems Manager to Run Commands on EC2 Instances?

Once you go to the server, you will see the web server installed.

How to Use AWS Systems Manager to Run Commands on EC2 Instances?

Leave a Comment