简体   繁体   中英

AWS SSM send-command to detach EBS storage?

I was trying to detach EBS storage from a Windows EC2 instance using SSM send-command with a target filter named EC2. Example:

aws ssm send-command --targets "Key=tag:Name,Values=MYWINDOWSServer" --document-name "AWS-RunShellScript" --parameter "commands = aws ec2 detach-volume --volume-id vol-00000xxxae64a1bd"

The tag name is unique so it should only be executing on 1 server in this account. The output I am getting is confusing and I can't get this working. Can someone point me in the right direction? Thanks in advance.

Output:

{
    "Command": {
        "CommandId": "934abae5-d28e-49f8-a5a8-a9a9f64c62cc",
        "DocumentName": "AWS-RunShellScript",
        "DocumentVersion": "$DEFAULT",
        "Comment": "",
        "ExpiresAfter": "2021-05-25T13:24:12.765000-04:00",
        "Parameters": {
            "commands": [
                "aws ec2 detach-volume --volume-id vol-00000xxxae64a1bd"
            ]
        },
        "InstanceIds": [],
        "Targets": [
            {
                "Key": "tag:Name",
                "Values": [
                    "MYWINDOWSServer"
                ]
            }
        ],
        "RequestedDateTime": "2021-05-25T10:24:12.765000-04:00",
        "Status": "Pending",
        "StatusDetails": "Pending",
        "OutputS3BucketName": "",
        "OutputS3KeyPrefix": "",
        "MaxConcurrency": "50",
        "MaxErrors": "0",
        "TargetCount": 0,
        "CompletedCount": 0,
        "ErrorCount": 0,
        "DeliveryTimedOutCount": 0,
        "ServiceRole": "",
        "NotificationConfig": {
            "NotificationArn": "",
            "NotificationEvents": [],
            "NotificationType": ""
        },
        "CloudWatchOutputConfig": {
            "CloudWatchLogGroupName": "",
            "CloudWatchOutputEnabled": false
        },
        "TimeoutSeconds": 3600
    }
}

This is the output of the ssm command that you ran. Once you run the SSM command it status is changed to pending and once the command gets completed it's status changes to success/failed/timed out depending on the outcome.

"Status": "Pending"

Similary, the output you see are all the argumets that return when you run a SSM command. Since this is in command line it is a bit over-whelming.

I would suggest you to look for this from SSM console in the Run command history. Look for the command ID: 934abae5-d28e-49f8-a5a8-a9a9f64c62cc

You will get to know if it completed or failed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM