Skip to content

Latest commit

 

History

History
130 lines (73 loc) · 8.28 KB

Project Guideline.md

File metadata and controls

130 lines (73 loc) · 8.28 KB

AWS_System_Manager

Using System Manager to run commands on EC2 instance AWS Systems Manager gives you visibility and control of your infrastructure on AWS. Systems Manager provides a unified user interface so you can view operational data from multiple AWS services and enables you to automate operational tasks across your AWS resources. ssm In this project, we will be going on a journey that will take you through your first AWS Systems Manager deployment, and it is an honor to be accompanying you. In this project, we will be going on a journey that will take you through your first AWS Systems Manager deployment, and it is an honor to be accompanying you.

Step 1 : IAM Role creation.

Okay lets get started, for us to be able to use Systems Manager to perfom operations we first need to create an IAM Role Profile for the EC2 instances.

Head over to AWS management console click the search box and type IAM, on the IAM console page at the left side you will see Roles under Access management.

iam_role

Here click the create Role at the right top corner. Under Trusted entity type select AWS service, scroll down to use cases and select EC2. ec2_role Now in the permissions policies search for “AmazonEC2RoleforSSM” first_role There is a message displaying under when you select the policy saying the policy will soon be deprecated. So we are told to use “AmazonSSMManagedInstanceCore” policy instead. guideline_second_role Now go back to the permissions policy and search for “AmazonSSMManagedInstanceCore” click the check box at the left to select it. correct_role Now give your Role a name and description. name_your_role Verify that it’s the correct policy that is selected, now scroll down and click “create role”. create_role

STEP 2 : EC2 Instance creation Here we launch instances that will be updated using systems manager.

ec2_console

Click launch instance.

os_selection_1 os_selection_2

Name your instance Select an operating system for your instance, leave the default AMI and Architecture

instance_type

Under instance type select the “Free tier eligible” ones, under keypair login select “ Proceed without a key pair”.

SG_2

Under Network settings click “ Select existing security group”.

SG_1

Select your default security group.

iam_instance-profile_select_1

Scroll down to “Advance Details” under “IAM instance profile” click and select the IAM role you created earlier.

IAM_instance-profile_select_2

Scroll down to “user data” and paste the following bash script from the Bash script file in the directory

Note: This script is as a result of the operating system I selected which is Redhat as a result system manager agent is not pre-installed in it.

So the script downloads and installs the systems manager agent and starts it.

Now in number of instance type 3 click launch instance.

ec2_launch

Great !!! you have successfully launch your instances.

STEP 3: USING SYSTEMS MANAGER TO RUN COMMANDS ON YOUR INSTANCE

Now head over to the Systems Manager, click Fleet Manager at the left side of the screen.

system_manager_console

Here your instances with Systems Manager Agent installed will be displayed. Select all three instances.

NOTE: If your instances are not displaying here that means the Systems Manager Agents was not successfully installed, so conect to the instance using SSH, and install the Systems Manager Agent for each instances.

node_selection

After selecting your instances click node action, select “Tools” and click “ Execute run command”.

node_action

In the search bar type in the type of command you want to excute.

select_command

For this project we will be using “AWS-RunShellScript” command, so type in the command select it from drop down list.

command_selected

Now scroll down to the command pallete,here we will writing a command to update the instances. Type “sudo yum update -y” .

command_line

Scroll down to target selection and select the instances that you want the command to be executed on.

target_selection

After selecting your targets click “Run”.

run_command

Your command status should show “ In progress”.

command_status_in-progress

If successful the overall status changes to “ Success”

command_status_sucessful

Congratulations you have successfully used system manager to update a set of instances.

STEP 4

session_manager_terminal

You head over to EC2, select one of the instances and connect using session manager, run the command “sudo yum update -y” you should a message saying “Nothing to do”.

Now you head over to step x in the command pallete type in “sudo shutdown” scroll down and select your targets which are the instances you want to shutdown, scroll and click run. Wait for the overall status to display success.

Congratulations you heard over to the EC2 console to terminate your instances.