sonic execute


sonic execute [FILTER] [COMMAND]


Runs command across fleet of servers via AWS Run Command.

  • A filter must be provided. The filter can be a mix of instance ids and ec2 tags.
  • The command can be provided inline or as a file. To a file use file:// at the beginning of your file.

Examples Summary

$ sonic execute hi-web-prod uptime
$ sonic execute hi-web-prod,hi-worker-prod,hi-clock-prod uptime
$ sonic execute i-030033c20c54bf149,i-030033c20c54bf150 uname -a
$ sonic execute i-030033c20c54bf149 file://

You cannot mix instance ids and tag names in the filter.

Example Detailed

Here’s a command example output in detailed:

$ sonic execute i-0bf51a000ab4e73a8 uptime
Sending command to SSM with options:
- i-0bf51a000ab4e73a8
document_name: AWS-RunShellScript
comment: sonic execute i-0bf51a000ab4e73a8 uptime
  - uptime
output_s3_region: us-east-1
output_s3_bucket_name: [reacted]
output_s3_key_prefix: ssm/commands/sonic

Command sent to AWS SSM. To check the details of the command:
  aws ssm list-commands --command-id 0bb18d58-6436-49fd-9bfd-0c4b6c51c7a2
  aws ssm get-command-invocation --command-id 0bb18d58-6436-49fd-9bfd-0c4b6c51c7a2 --instance-id i-0bf51a000ab4e73a8

Waiting for ssm command to finish.....
Command finished.

Displaying output for i-0bf51a000ab4e73a8.
Command status: Success
Command standard output:
 01:08:10 up 8 days,  6:41,  0 users,  load average: 0.00, 0.00, 0.00

To see the more output details visit:

Pro tip: the console url is already in your copy/paste clipboard.

Notice the conveniences of sonic execute, it:

  1. Showed the parameters that will be sent as part of the send_command call to SSM.
  2. Sent the command to SSM.
  3. Waited for the command to finish.
  4. Displayed the output of the command.
  5. Provided the console url that visit to view more details about the SSM command.

The AWS SSM console looks like this:


[--zero-warn], [--no-zero-warn]  # Warns user when no instances found
                                 # Default: true
[--verbose], [--no-verbose]      
[--noop], [--no-noop]            

Edit this page

See a typo or an error? You can improve this page. This website is available on GitHub and contributions are encouraged and welcomed. We love pull requests from you!