Menu
Amazon Elastic Compute Cloud
User Guide for Linux Instances

SSM Run Command Walkthrough Using the Amazon EC2 Console

The following sample walkthrough shows you how to execute commands with Run Command using the Commands page in the Amazon EC2 console. You will learn how to execute a command with the AWS-RunShellScript SSM document. To view CLI examples, see SSM Run Command Walkthrough Using the AWS CLI.

  1. In the Amazon EC2 console choose Commands in the navigation pane, and then choose Run a command.

    Accessing Commands page in the Amazon EC2 console
  2. In the Command document list, choose AWS-RunShellScript.

    Selecting a command document
  3. Choose Select instances and then choose the instances where you want to execute the command. If you do not see a complete list of instances, the missing instances might not be configured properly for Run Command. For more information, see SSM Run Command Prerequisites.

    Choosing instances for Run Command
  4. Type a valid shell script or command in the Commands field. You can specify a Working Directory and Execution Timeout, if you want. The Execution Timeout is the number of seconds the amazon-ssm-agent will attempt to run the command before it is considered to have failed. We recommend entering a comment in the Comments field. A comment will help you identify the command in the list of pending commands and make it easier to view the output.

    Entering a command and comment
  5. In the Timeout (seconds) field, type the number of seconds Run Command should attempt to reach instances before an instance is considered unreachable and the command execution fails.

  6. In the S3 bucket field type the name of an Amazon S3 bucket where you want to store command output. Enter an Amazon S3 subfolder in the S3 key prefix field. A subfolder can help you organize output if you are executing multiple commands against multiple instances.

    Entering Timeout and S3 fields for Run Command
  7. Choose Run to execute the command simultaneously on the selected instances. Run Command displays a status screen.

  8. Choose View result.

    Command status screen
  9. The command list shows three invocations for the command because it was sent to three instances. Each invocation has it's own Command ID and status. To view status, choose an invocation, choose the Output tab for the invocation, and then choose View Output.

    List of commands executed with Run Command
  10. The system displays the output in your browser. If the output is longer than 2500 characters, only the first 2500 characters are shown and the rest is truncated.

    Command output from the Amazon EC2 console
  11. You can view the full command output in Amazon S3. Open the S3 console and choose your Amazon S3 bucket.

    Amazon S3 bucket with Run Command output
  12. Choose the Command-ID.Instance-ID for which you want to view command output.

    Command output in instance ID sub-folders
  13. Choose the awsrunShellScript sub-folder.

    Run Command sub-folder for awsrunShellScript
  14. Choose the stdout.text file. Amazon S3 displays the full command output.

    Full command output in S3.