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.
In the Amazon EC2 console choose Commands in the navigation pane, and then choose Run a command.

In the Command document list, choose AWS-RunShellScript.

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.

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.

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.
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.

Choose Run to execute the command simultaneously on the selected instances. Run Command displays a status screen.
Choose View result.

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.

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.

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

Choose the
Command-ID.Instance-IDfor which you want to view command output.
Choose the awsrunShellScript sub-folder.

Choose the stdout.text file. Amazon S3 displays the full command output.


