Menu
Amazon EC2 Systems Manager
User Guide

Systems Manager State Manager Walkthroughs

Use the following walkthrough to create a State Manager association for an EC2 instance in a test environment.

Systems Manager State Manager CLI Walkthrough

The following procedure walks you through the process of creating a State Manager association using the AWS Command Line Interface (AWS CLI).

  1. Copy one of the following sample documents and paste it into a simple text editor like Notepad.

    Linux

    Copy
    { "schemaVersion": "2.0", "description": "Sample version 2.0 document v2", "parameters": { }, "mainSteps": [ { "action": "aws:runShellScript", "name": "runShellScript", "inputs": { "runCommand": [ "ifconfig" ] } } ] }

    Windows

    Copy
    { "schemaVersion": "2.0", "description": "Sample version 2.0 document v2", "parameters": { }, "mainSteps": [ { "action": "aws:runPowerShellScript", "name": "runShellScript", "inputs": { "runCommand": [ "ipconfig" ] } }, { "action": "aws:applications", "name": "installapp", "inputs": { "action": "Install", "source": "http://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-5.6.22.0.msi" } } ] }
  2. Save the document with a descriptive name and a .json file extension.

  3. Execute the following command to create the document and save it with your AWS user account using the AWS CLI.

    Copy
    aws ssm create-document --document-type "Command" --content file://c:\temp\your file --name "a name for the document"
  4. Execute the following command to create an association. The Schedule parameter sets a schedule to run the association every 30 minutes.

    Copy
    aws ssm create-association --targets Key=instanceids,Values=Instance ID --name your document name --schedule "cron(0 0/30 * 1/1 * ? *)"
  5. Execute the following command to view the associations for the instance.

    Copy
    aws ssm list-associations

On this page: