March 24, 2021 / Nirav Shah
Run Command Remotely on EC2 instance: AWS Manager
Learn how to manage Instance using AWS-SSM and how we create a session manager for the system.
Step 1: Create an IAM role that will be used to give the Systems Manager permission to perform actions on your instances.
choose EC2 and On the Attached permissions policy page, in the search bar type AmazonEC2RoleforSSM then from the policy list, then select AmazonEC2RoleforSSM, and then choose Next: Review.
Step 2: Create an EC2 instance
In this step, you will create an EC2 instance using the EnablesEC2ToAccessSystemsManagerRole role.
Step 3: Update the Systems Manager Agent. Open Systems Manager from the Systems Manager console.
Step 4: On the Managed instances page, in the Actions drop-down select Run Command.
Step 5: On the Run command, click in the search bar and select Document name prefix, then click on Equal, then type in AWS-UpdateSSMAgent.
Scroll down to the Targets panel and click the check box next to your managed EC2 instance.
Step 6: Run a Remote Shell Script
From the Systems Management console, in the left nav under Shared Resources select Managed instances. Then in the Actions menu, select the Run Command menu item.
Step 7:
Step 8: Insert the following command in the Commands text box:
sudo yum update -y
Finally, scroll down and select Run.
Now check in your EC2 Instance for the output. This is how you can run the command remotely on EC2 instance.
As a Director of Eternal Web Private Ltd an AWS consulting partner company, Nirav is responsible for its operations. AWS, cloud-computing and digital transformation are some of his favorite topics to talk about. His key focus is to help enterprises adopt technology, to solve their business problem with the right cloud solutions.
Have queries about your project idea or concept? Please drop in your project details to discuss with our AWS Global Cloud Infrastructure service specialists and consultants.