Run Command and State Manager are two core features of the SSM service. They enable users to administer managed hybrid infrastructure remotely as well as maintain persistent configurations on instances on a schedule. Both of these features are used heavily during basic SSM tasks such as Session Manager sessions (Run Command) and querying and maintaining systems inventory (via State Manager associations).
These features can be extremely handy when remotely managing a ton of systems spread across different cloud providers and on-prem datacenter.
State Manager Associations can prove useful in enforcing a fixed configuration across your fleet of instances thereby reducing their drift from standard configuration over time.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Log in and Head to AWS Systems Manager Console
Log in to the AWS Management Console and head to AWS Systems Manager console.
- Check Managed Instance, Run Command, and State Manager Association
Ensure that under the Fleet Manager page, you see that pre-configured SSM EC2 Linux instance.<br/>
TheName
tag of that instance isSSMInstance
.This instance has been set up by the lab environment for you and we’ll be performing some Run Command and State Manager association tasks on it, such as:
- Auto-updating the SSM Agent (which establishes and runs a State Manager association)
- Using a Run Command to configure and install Docker on the SSM EC2 instance
- Auto update SSM agent
Once you’re on the
Fleet Manager
page, under The AWS Systems Manager console on AWS GUI.
<br/>
Click on theAccount management
button and chooseAuto-update SSM agent
button at the top of the Managed instance selection area.
This basically, sets up a persistent SSM State Manager association which periodically checks your managed instances for older versions of SSM agent and updates it.
<br/>
Once you click the button you’ll be given a prompt with description of what the SSM service will do, go ahead and click onAuto update SSM agent
.<br/>
Now head toState Manager
from the SSM features navigation pane on left hand side to track the progress of the association which will help update your SSM agent(s).
After it completes successfully, you’ll note that on theFleet Manager
page your SSM agent version column will reflect the latest version your agent was updated to.- Execute a Run Command Document
On your AWS Systems Manager console, head towards the
Run Command
page from the SSM features navigation pane to the left. <br/>- Click on
Run Command
button to the right top side of your screen, which will take you to the selection of Document to execute during Run Command. - Choose the Document
AWS-ConfigureDocker
(click on the radio button next to it), alternatively you can also click on the search bar which will give a drop down for narrowing search against specific OS, Document types etc. - Leave
Document Version
to default - Leave command parameters to default as well(these parameters are basically input to the Run Command)
- Under
Targets
, selectChoose instance manually
. TheSSMInstance
should show up, select it. - Leave
Other Parameters
andRate Control
to default and uncheckEnable writing to an S3 bucket
option underOutputs
. - Leave everything else to default and click on
Run
.
You’ll be taken to the
Run Command
page with the details and progress of the Run Command that you just issued.- Click on
- Verify Run Command
You can verify that Run Command was run successfully either by logging into the EC2 instance via SSH or Session Manager session and issuing commands such as:
systemctl status docker #to check it it's running docker ps
Remember that the objective of this lab is to verify installation not the functionality and docker commands, if the docker daemon is not running you can start it with:
sudo service docker status
For logging in via Session Manager, head to Session Manager page from the AWS Systems Manager console, click on
Start Session
and on the next page which loads, select yourSSMInstance
and click onStart Session
again.