Sitemap
AWS Tip

Best AWS, DevOps, Serverless, and more from top Medium writers .

AWS Systems Manager

--

A hands-on project on getting started with AWS Systems Manager.

Press enter or click to view image in full size

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 honour to be accompanying you.

Step 1 : IAM Role creation.

Okay lets get started, for us to be able to use Systems Manager to perform 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.

Press enter or click to view image in full size

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.

Press enter or click to view image in full size

Now in the permissions policies search for “AmazonEC2RoleforSSM”

Press enter or click to view image in full size

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.

Press enter or click to view image in full size

Now go back to the permissions policy and search for “AmazonSSMManagedInstanceCore” click the check box at the left to select it.

Press enter or click to view image in full size

Now give your Role a name and description.

Press enter or click to view image in full size

Verify that it’s the correct policy that is selected, now scroll down and click “create role”.

Press enter or click to view image in full size

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

Press enter or click to view image in full size

Click launch instance.

Press enter or click to view image in full size
Press enter or click to view image in full size

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

Press enter or click to view image in full size

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

Press enter or click to view image in full size

Under Network settings click “ Select existing security group”.

Press enter or click to view image in full size

Select your default security group.

Press enter or click to view image in full size

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

Press enter or click to view image in full size

Scroll down to “user data” and paste the following bash script from the Bash script below

Get Michael Chidiogo Okoli’s stories in your inbox

Join Medium for free to get updates from this writer.

https://github.com/McTello/AWS_System_Manager/blob/909b286aca112db660378dd70f026719847ac330/Bash_script.sh

#/bin/bash

sudo dnf install -y https:/ /s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm

sudo systemctl enable amazon-ssm-agentpm

sudo systemctl start amazon-ssm-agent

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.

Press enter or click to view image in full size

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.

Press enter or click to view image in full size

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.

Press enter or click to view image in full size

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

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

Press enter or click to view image in full size

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

Press enter or click to view image in full size

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

Press enter or click to view image in full size

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

Press enter or click to view image in full size

After selecting your targets click “Run”.

Press enter or click to view image in full size

Your command status should show “ In progress”.

Press enter or click to view image in full size

If successful the overall status changes to “ Success”

Press enter or click to view image in full size

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

STEP 4

Press enter or click to view image in full size

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.

--

--

Michael Chidiogo Okoli
Michael Chidiogo Okoli

Written by Michael Chidiogo Okoli

Highly skilled and versatile Cloud Engineer and Systems Administrator | AWS 3x Certified. Email: contact@diogomic.me

AWS Tip
AWS Tip

Published in AWS Tip

Best AWS, DevOps, Serverless, and more from top Medium writers .