Private
Server IP : 195.201.23.43  /  Your IP : 3.145.85.212
Web Server : Apache
System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64
User : kdecoratie ( 1041)
PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/awscli/examples/ssm/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /lib/python3/dist-packages/awscli/examples/ssm/send-command.rst
**Example 1: To run a command on one or more remote instances**

The following ``send-command`` example runs an ``echo`` command on a target instance. ::

    aws ssm send-command \
        --document-name "AWS-RunShellScript" \
        --parameters commands=["echo HelloWorld"] \
        --targets "Key=instanceids,Values=i-1234567890abcdef0" \
        --comment "echo HelloWorld"
  
Output::

    {
        "Command": {
            "CommandId": "92853adf-ba41-4cd6-9a88-142d1EXAMPLE",
            "DocumentName": "AWS-RunShellScript",
            "DocumentVersion": "",
            "Comment": "echo HelloWorld",
            "ExpiresAfter": 1550181014.717,
            "Parameters": {
                "commands": [
                    "echo HelloWorld"
                ]
            },
            "InstanceIds": [
                "i-0f00f008a2dcbefe2"
            ],
            "Targets": [],
            "RequestedDateTime": 1550173814.717,
            "Status": "Pending",
            "StatusDetails": "Pending",
            "OutputS3BucketName": "",
            "OutputS3KeyPrefix": "",
            "MaxConcurrency": "50",
            "MaxErrors": "0",
            "TargetCount": 1,
            "CompletedCount": 0,
            "ErrorCount": 0,
            "DeliveryTimedOutCount": 0,
            "ServiceRole": "",
            "NotificationConfig": {
                "NotificationArn": "",
                "NotificationEvents": [],
                "NotificationType": ""
            },
            "CloudWatchOutputConfig": {
                "CloudWatchLogGroupName": "",
                "CloudWatchOutputEnabled": false
            }
        }
    }

**Examle 2: To get IP information about an instance**

The following ``send-command`` example retrieves the IP information about an instance. ::

    aws ssm send-command \
        --instance-ids "i-1234567890abcdef0" \
        --document-name "AWS-RunShellScript" \
        --comment "IP config" \
        --parameters "commands=ifconfig"

**Example 3: To run a command on instances with specific tags**

The following ``send-command`` example runs a command on instances that have the tag key "ENV" and the value "Dev". ::

    aws ssm send-command \
        --targets "Key=tag:ENV,Values=Dev" \
        --document-name "AWS-RunShellScript" \
        --parameters "commands=ifconfig"

**Example 4: To run a command that sends SNS notifications**

The following ``send-command`` example runs a command that sends SNS notifications for all notification events and the ``Command`` notification type. ::

    aws ssm send-command \
        --instance-ids "i-1234567890abcdef0" \
        --document-name "AWS-RunShellScript" \
        --comment "IP config" \
        --parameters "commands=ifconfig" \
        --service-role-arn "arn:aws:iam::123456789012:role/SNS_Role" \
        --notification-config "NotificationArn=arn:aws:sns:us-east-1:123456789012:SNSTopicName,NotificationEvents=All,NotificationType=Command"

**Example 5: To run a command that outputs to S3 and CloudWatch**

The following ``send-command`` example runs a command that outputs command details to an S3 bucket and to a CloudWatch Logs log group. ::

    aws ssm send-command \
        --instance-ids "i-1234567890abcdef0" \
        --document-name "AWS-RunShellScript" \
        --comment "IP config" \
        --parameters "commands=ifconfig" \
        --output-s3-bucket-name "s3-bucket-name" \
        --output-s3-key-prefix "runcommand" \
        --cloud-watch-output-config "CloudWatchOutputEnabled=true,CloudWatchLogGroupName=CWLGroupName"

**Example 6: To run commands on multiple instances with different tags**

The following ``send-command`` example runs a command on instances with two different tag keys and values. ::

    aws ssm send-command \
        --document-name "AWS-RunPowerShellScript" \
        --parameters commands=["echo helloWorld"] \
        --targets Key=tag:Env,Values=Dev Key=tag:Role,Values=WebServers

**Example 7: To target multiple instances with the same tag key**

The following ``send-command`` example runs a command on instances that have the same tag key but with different values. ::

    aws ssm send-command \
        --document-name "AWS-RunPowerShellScript" \
        --parameters commands=["echo helloWorld"] \
        --targets Key=tag:Env,Values=Dev,Test

For more information, see `Running Commands Using Systems Manager Run Command <https://docs.aws.amazon.com/systems-manager/latest/userguide/run-command.html>`__ in the *AWS Systems Manager User Guide*.
Private