Please, Protect My AWS! : Systems Manager-Run Command

sundaeGAN
4 min readFeb 17, 2024

--

Image from : https://allcode.com/best-practices-for-using-aws-systems-manager/

What is the Systems Manager?

  • This is an AWS Resource that assists us in automating Infrastructure configuration, performance optimization, and patch management.

In this series, i’m planning to focus on just two features of it : ‘Run Command’ and ‘Patch Manager’.

Then, what is the Run Command?

  • You can send a command to multiple instances simultaneously.
  • And you can also get a result from it.
  • So, it’s useful for provisioning.

How?

First of all, you need to create three or more EC2 instances to test Run command.(For who doesn’t know how to create an EC2 instance : https://medium.com/@jenjenjelly/please-protect-my-aws-amazon-inspector-classic-8814a521d268)

When you create the instances, you’d better set the tag so that you can execute the ‘Run command’ easily.

In my case, I prepared three instances for testing.

Here’s one more thing to do. You need to set the IAM instance profile that has permission for SSM(System Manager). For who doesn’t know how to create the IAM instance profile, click this : https://medium.com/@jenjenjelly/please-protect-my-aws-amazon-inspector-v2-3c41e70da41a

Search for ‘Systems Manager’.

When you scroll down the left-side bar, you can find the Run Command in the Node Management section. *Click

Click ‘Run command’ button.

There are so many types of command we can execute.

We are going to execute a shell script. You can find it by searching in the bar above.

I wanna execute these commands. Feel free to type the command you want.

When you scroll down, you can see the Target selection section. Specify the tags of your instances.

Uncheck the checkbox, cuz we are not going to save the result.

And, click the Run button.

Then, you can see the result.

If you want to see the more specific result, you can see that by clicking your instances’ ID.

As you can see, the commands were executed successfully. But we can also know that the ‘Run command’ executes the commands as a root. Be careful.

Let’s check the directory we specified before.

Alright, it made the directory we want..

Thank u ;)

--

--