Managing Infrastructure State with State Manager and Run Command

45 minutes
  • 5 Learning Objectives

About this Hands-on Lab

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 Managed Instances page, you see that pre-configured SSM EC2 Linux instance.<br/>
The Name tag of that instance is SSMInstance.

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 Managed Instances page, under The AWS Systems Manager console on AWS GUI.
Click on the Agent auto update 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.
Once you click the button you’ll be given a prompt with description of what the SSM service will do, go ahead and click on Auto update SSM agent.<br/>
Now head to State 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 the Managed Instances 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/>

  1. 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.
  2. 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. So if the AWS-ConfigureDocker document is not showing in the default shown documents, click on the search bar, select Platform types and select Linux which should provide this document in the top few search results.
  3. Leave Document Version to default
  4. Leave command parameters to default as well(these parameters are basically input to the Run Command)
  5. Under Targets, select Choose instance manually. The SSMInstance should show up, select it.
  6. Leave Other Parameters and Rate Control to default and uncheck Enable writing to an S3 bucket option under Outputs.
  7. 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.

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 your SSMInstance and click on Start Session again.

Additional Resources

Log in to the live AWS environment using the credentials provided. Make sure you're in the N. Virginia (us-east-1) region throughout the lab.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?