자습서: 유지 관리 기간에 대한 정보 보기(AWS CLI) - AWS Systems Manager

자습서: 유지 관리 기간에 대한 정보 보기(AWS CLI)

이 자습서에는 유지 관리 기간, 작업, 실행 및 호출에 대한 정보를 업데이트하거나 얻는 데 도움이 되는 명령이 포함되어 있습니다. 명령 옵션을 사용하여 보려는 세부 정보 유형을 필터링하는 방법을 보여주는 예제가 명령별로 정리되어 있습니다.

이 튜토리얼의 단계를 수행하면서 빨간색 기울임꼴 텍스트의 값을 원하는 옵션 및 ID로 바꿉니다. 예를 들어 유지 관리 기간 ID mw-0c50858d01EXAMPLE과 인스턴스 ID i-02573cafcfEXAMPLE을 생성하는 리소스의 ID로 바꿉니다.

AWS Command Line Interface(AWS CLI) 설정 및 구성에 대한 자세한 내용은 AWS CLI 구성AWS CLI 설치, 업데이트 및 제거를 참조하세요.

'describe-maintenance-windows'에 대한 예제

AWS 계정에 모든 유지 관리 기간 나열

다음 명령을 실행합니다.

aws ssm describe-maintenance-windows

시스템은 다음과 같은 정보를 반환합니다.

{
   "WindowIdentities":[
      {
         "WindowId":"mw-0c50858d01EXAMPLE",
         "Name":"My-First-Maintenance-Window",
         "Enabled":true,
         "Duration":2,
         "Cutoff":0,
         "NextExecutionTime": "2019-05-18T17:01:01.137Z"        
      },
      {
         "WindowId":"mw-9a8b7c6d5eEXAMPLE",
         "Name":"My-Second-Maintenance-Window",
         "Enabled":true,
         "Duration":4,
         "Cutoff":1,
         "NextExecutionTime": "2019-05-30T03:30:00.137Z"        
      },
   ]
}

활성화된 모든 유지 관리 기간 나열

다음 명령을 실행합니다.

aws ssm describe-maintenance-windows --filters "Key=Enabled,Values=true"

시스템은 다음과 같은 정보를 반환합니다.

{
   "WindowIdentities":[
      {
         "WindowId":"mw-0c50858d01EXAMPLE",
         "Name":"My-First-Maintenance-Window",
         "Enabled":true,
         "Duration":2,
         "Cutoff":0,
         "NextExecutionTime": "2019-05-18T17:01:01.137Z"        
      },
      {
         "WindowId":"mw-9a8b7c6d5eEXAMPLE",
         "Name":"My-Second-Maintenance-Window",
         "Enabled":true,
         "Duration":4,
         "Cutoff":1,
         "NextExecutionTime": "2019-05-30T03:30:00.137Z"        
      },
   ]
}

비활성화된 모든 유지 관리 기간 나열

다음 명령을 실행합니다.

aws ssm describe-maintenance-windows --filters "Key=Enabled,Values=false"

시스템은 다음과 같은 정보를 반환합니다.

{
    "WindowIdentities": [
        {
            "WindowId": "mw-6e5c9d4b7cEXAMPLE",
            "Name": "My-Disabled-Maintenance-Window",
            "Enabled": false,
            "Duration": 2,
            "Cutoff": 1
        }
    ]
}

이름이 특정 접두사로 시작하는 모든 유지 관리 기간 나열

다음 명령을 실행합니다.

aws ssm describe-maintenance-windows --filters "Key=Name,Values=My"

시스템은 다음과 같은 정보를 반환합니다.

{
    "WindowIdentities": [
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window",
            "Enabled": true,
            "Duration": 2,
            "Cutoff": 0,
            "NextExecutionTime": "2019-05-18T17:01:01.137Z"
        },
        {
            "WindowId": "mw-9a8b7c6d5eEXAMPLE",
            "Name": "My-Second-Maintenance-Window",
            "Enabled": true,
            "Duration": 4,
            "Cutoff": 1,
            "NextExecutionTime": "2019-05-30T03:30:00.137Z"
        },
        {
            "WindowId": "mw-6e5c9d4b7cEXAMPLE",
            "Name": "My-Disabled-Maintenance-Window",
            "Enabled": false,
            "Duration": 2,
            "Cutoff": 1
        }
    ]
}

'describe-maintenance-window-targets'에 대한 예제

특정 소유자 정보 값과 일치하는 유지 관리 기간의 대상 표시

다음 명령을 실행합니다.

Linux & macOS
aws ssm describe-maintenance-window-targets \ --window-id "mw-6e5c9d4b7cEXAMPLE" \ --filters "Key=OwnerInformation,Values=CostCenter1"
Windows
aws ssm describe-maintenance-window-targets ^ --window-id "mw-6e5c9d4b7cEXAMPLE" ^ --filters "Key=OwnerInformation,Values=CostCenter1"
참고

지원되는 필터 키는 Type, WindowTargetIdOwnerInformation입니다.

시스템은 다음과 같은 정보를 반환합니다.

{
    "Targets": [
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "WindowTargetId": "e32eecb2-646c-4f4b-8ed1-205fbEXAMPLE",
            "ResourceType": "INSTANCE",
            "Targets": [
                {
                    "Key": "tag:Name",
                    "Values": [
                        "Production"
                    ]
                }
            ],
            "OwnerInformation": "CostCenter1",
            "Name": "Target1"
        }
    ]
}

'describe-maintenance-window-tasks'에 대한 예제

SSM 명령 문서 AWS-RunPowerShellScript를 호출하는 모든 등록된 태스크 표시

다음 명령을 실행합니다.

Linux & macOS
aws ssm describe-maintenance-window-tasks \ --window-id "mw-0c50858d01EXAMPLE" \ --filters "Key=TaskArn,Values=AWS-RunPowerShellScript"
Windows
aws ssm describe-maintenance-window-tasks ^ --window-id "mw-0c50858d01EXAMPLE" ^ --filters "Key=TaskArn,Values=AWS-RunPowerShellScript"

시스템은 다음과 같은 정보를 반환합니다.

{
   "Tasks":[
      {
         "ServiceRoleArn": "arn:aws:iam::111122223333:role/MyMaintenanceWindowServiceRole",
         "MaxErrors":"1",
         "TaskArn":"AWS-RunPowerShellScript",
         "MaxConcurrency":"1",
         "WindowTaskId":"4f7ca192-7e9a-40fe-9192-5cb15EXAMPLE",
         "TaskParameters":{
            "commands":{
               "Values":[
                  "driverquery.exe"
               ]
            }
         },
         "Priority":3,
         "Type":"RUN_COMMAND",
         "Targets":[
            {
               "TaskTargetId":"i-02573cafcfEXAMPLE",
               "TaskTargetType":"INSTANCE"
            }
         ]
      },
      {
         "ServiceRoleArn":"arn:aws:iam::111122223333:role/MyMaintenanceWindowServiceRole",
         "MaxErrors":"1",
         "TaskArn":"AWS-RunPowerShellScript",
         "MaxConcurrency":"1",
         "WindowTaskId":"4f7ca192-7e9a-40fe-9192-5cb15EXAMPLE",
         "TaskParameters":{
            "commands":{
               "Values":[
                  "ipconfig"
               ]
            }
         },
         "Priority":1,
         "Type":"RUN_COMMAND",
         "Targets":[
            {
               "TaskTargetId":"i-02573cafcfEXAMPLE",
               "TaskTargetType":"WINDOW_TARGET"
            }
         ]
      }
   ]
}

우선순위가 “3”인 모든 등록된 작업 표시

다음 명령을 실행합니다.

Linux & macOS
aws ssm describe-maintenance-window-tasks \ --window-id "mw-9a8b7c6d5eEXAMPLE" \ --filters "Key=Priority,Values=3"
Windows
aws ssm describe-maintenance-window-tasks ^ --window-id "mw-9a8b7c6d5eEXAMPLE" ^ --filters "Key=Priority,Values=3"

시스템은 다음과 같은 정보를 반환합니다.

{
   "Tasks":[
      {
         "ServiceRoleArn":"arn:aws:iam::111122223333:role/MyMaintenanceWindowServiceRole",
         "MaxErrors":"1",
         "TaskArn":"AWS-RunPowerShellScript",
         "MaxConcurrency":"1",
         "WindowTaskId":"4f7ca192-7e9a-40fe-9192-5cb15EXAMPLE",
         "TaskParameters":{
            "commands":{
               "Values":[
                  "driverquery.exe"
               ]
            }
         },
         "Priority":3,
         "Type":"RUN_COMMAND",
         "Targets":[
            {
               "TaskTargetId":"i-02573cafcfEXAMPLE",
               "TaskTargetType":"INSTANCE"
            }
         ]
      }
   ]
}

우선순위가 '1'인 모든 등록된 작업 표시 및 Run Command 사용

다음 명령을 실행합니다.

Linux & macOS
aws ssm describe-maintenance-window-tasks \ --window-id "mw-0c50858d01EXAMPLE" \ --filters "Key=Priority,Values=1" "Key=TaskType,Values=RUN_COMMAND"
Windows
aws ssm describe-maintenance-window-tasks ^ --window-id "mw-0c50858d01EXAMPLE" ^ --filters "Key=Priority,Values=1" "Key=TaskType,Values=RUN_COMMAND"

시스템은 다음과 같은 정보를 반환합니다.

{
    "Tasks": [
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "WindowTaskId": "4f7ca192-7e9a-40fe-9192-5cb15EXAMPLE",
            "TaskArn": "AWS-RunShellScript",
            "Type": "RUN_COMMAND",
            "Targets": [
                {
                    "Key": "InstanceIds",
                    "Values": [
                        "i-02573cafcfEXAMPLE"
                    ]
                }
            ],
            "TaskParameters": {},
            "Priority": 1,
            "ServiceRoleArn": "arn:aws:iam::111122223333:role/MyMaintenanceWindowServiceRole",
            "MaxConcurrency": "1",
            "MaxErrors": "1"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "WindowTaskId": "8a5c4629-31b0-4edd-8aea-33698EXAMPLE",
            "TaskArn": "AWS-UpdateSSMAgent",
            "Type": "RUN_COMMAND",
            "Targets": [
                {
                    "Key": "InstanceIds",
                    "Values": [
                        "i-0471e04240EXAMPLE"
                    ]
                }
            ],
            "TaskParameters": {},
            "Priority": 1,
            "ServiceRoleArn": "arn:aws:iam::111122223333:role/MyMaintenanceWindowServiceRole",
            "MaxConcurrency": "1",
            "MaxErrors": "1",
            "Name": "My-Run-Command-Task",
            "Description": "My Run Command task to update SSM Agent on an instance"
        }
    ]
}

'describe-maintenance-windows-for-target'에 대한 예제

특정 노드와 관련된 유지 관리 기간 대상 또는 작업에 대한 정보 나열

다음 명령을 실행합니다.

Linux & macOS
aws ssm describe-maintenance-windows-for-target \ --resource-type INSTANCE \ --targets "Key=InstanceIds,Values=i-02573cafcfEXAMPLE" \ --max-results 10
Windows
aws ssm describe-maintenance-windows-for-target ^ --resource-type INSTANCE ^ --targets "Key=InstanceIds,Values=i-02573cafcfEXAMPLE" ^ --max-results 10

시스템은 다음과 같은 정보를 반환합니다.

{
    "WindowIdentities": [
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window"
        },
        {
            "WindowId": "mw-9a8b7c6d5eEXAMPLE",
            "Name": "My-Second-Maintenance-Window"
        }
    ]
}

'describe-maintenance-window-executions'에 대한 예제

특정 날짜 이전에 실행된 모든 작업 나열

다음 명령을 실행합니다.

Linux & macOS
aws ssm describe-maintenance-window-executions \ --window-id "mw-9a8b7c6d5eEXAMPLE" \ --filters "Key=ExecutedBefore,Values=2019-05-12T05:00:00Z"
Windows
aws ssm describe-maintenance-window-executions ^ --window-id "mw-9a8b7c6d5eEXAMPLE" ^ --filters "Key=ExecutedBefore,Values=2019-05-12T05:00:00Z"

시스템은 다음과 같은 정보를 반환합니다.

{
    "WindowExecutions": [
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "WindowExecutionId": "14bea65d-5ccc-462d-a2f3-e99c8EXAMPLE",
            "Status": "FAILED",
            "StatusDetails": "The following SSM parameters are invalid: LevelUp",
            "StartTime": 1557617747.993,
            "EndTime": 1557617748.101
        },
        {
            "WindowId": "mw-9a8b7c6d5eEXAMPLE",
            "WindowExecutionId": "791b72e0-f0da-4021-8b35-f95dfEXAMPLE",
            "Status": "SUCCESS",
            "StartTime": 1557594085.428,
            "EndTime": 1557594090.978
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "WindowExecutionId": "ecec60fa-6bb0-4d26-98c7-140308EXAMPLE",
            "Status": "SUCCESS",
            "StartTime": 1557593793.483,
            "EndTime": 1557593798.978
        }
    ]
}

특정 날짜 이후에 실행된 모든 작업 나열

다음 명령을 실행합니다.

Linux & macOS
aws ssm describe-maintenance-window-executions \ --window-id "mw-9a8b7c6d5eEXAMPLE" \ --filters "Key=ExecutedAfter,Values=2018-12-31T17:00:00Z"
Windows
aws ssm describe-maintenance-window-executions ^ --window-id "mw-9a8b7c6d5eEXAMPLE" ^ --filters "Key=ExecutedAfter,Values=2018-12-31T17:00:00Z"

시스템은 다음과 같은 정보를 반환합니다.

{
    "WindowExecutions": [
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "WindowExecutionId": "14bea65d-5ccc-462d-a2f3-e99c8EXAMPLE",
            "Status": "FAILED",
            "StatusDetails": "The following SSM parameters are invalid: LevelUp",
            "StartTime": 1557617747.993,
            "EndTime": 1557617748.101
        },
        {
            "WindowId": "mw-9a8b7c6d5eEXAMPLE",
            "WindowExecutionId": "791b72e0-f0da-4021-8b35-f95dfEXAMPLE",
            "Status": "SUCCESS",
            "StartTime": 1557594085.428,
            "EndTime": 1557594090.978
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "WindowExecutionId": "ecec60fa-6bb0-4d26-98c7-140308EXAMPLE",
            "Status": "SUCCESS",
            "StartTime": 1557593793.483,
            "EndTime": 1557593798.978
        }
    ]
}

'describe-maintenance-window-schedule'에 대한 예제

특정 노드에 대해 예약된 다음 10개 유지 관리 기간 실행 표시

다음 명령을 실행합니다.

Linux & macOS
aws ssm describe-maintenance-window-schedule \ --resource-type INSTANCE \ --targets "Key=InstanceIds,Values=i-07782c72faEXAMPLE" \ --max-results 10
Windows
aws ssm describe-maintenance-window-schedule ^ --resource-type INSTANCE ^ --targets "Key=InstanceIds,Values=i-07782c72faEXAMPLE" ^ --max-results 10

시스템은 다음과 같은 정보를 반환합니다.

{
    "ScheduledWindowExecutions": [
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window",
            "ExecutionTime": "2019-05-18T23:35:24.902Z"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window",
            "ExecutionTime": "2019-05-25T23:35:24.902Z"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window",
            "ExecutionTime": "2019-06-01T23:35:24.902Z"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window",
            "ExecutionTime": "2019-06-08T23:35:24.902Z"
        },
        {
            "WindowId": "mw-9a8b7c6d5eEXAMPLE",
            "Name": "My-Second-Maintenance-Window",
            "ExecutionTime": "2019-06-15T23:35:24.902Z"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window",
            "ExecutionTime": "2019-06-22T23:35:24.902Z"
        },
        {
            "WindowId": "mw-9a8b7c6d5eEXAMPLE",
            "Name": "My-Second-Maintenance-Window",
            "ExecutionTime": "2019-06-29T23:35:24.902Z"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window",
            "ExecutionTime": "2019-07-06T23:35:24.902Z"
        },
        {
            "WindowId": "mw-9a8b7c6d5eEXAMPLE",
            "Name": "My-Second-Maintenance-Window",
            "ExecutionTime": "2019-07-13T23:35:24.902Z"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window",
            "ExecutionTime": "2019-07-20T23:35:24.902Z"
        }
    ],
    "NextToken": "AAEABUXdceT92FvtKld/dGHELj5Mi+GKW/EXAMPLE"
}

특정 키 값 페어로 태그가 지정된 노드에 대한 유지 관리 기간 일정 표시

다음 명령을 실행합니다.

Linux & macOS
aws ssm describe-maintenance-window-schedule \ --resource-type INSTANCE \ --targets "Key=tag:prod,Values=rhel7"
Windows
aws ssm describe-maintenance-window-schedule ^ --resource-type INSTANCE ^ --targets "Key=tag:prod,Values=rhel7"

시스템은 다음과 같은 정보를 반환합니다.

{
    "ScheduledWindowExecutions": [
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "DemoRateStartDate",
            "ExecutionTime": "2019-10-20T05:34:56-07:00"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "DemoRateStartDate",
            "ExecutionTime": "2019-10-21T05:34:56-07:00"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "DemoRateStartDate",
            "ExecutionTime": "2019-10-22T05:34:56-07:00"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "DemoRateStartDate",
            "ExecutionTime": "2019-10-23T05:34:56-07:00"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "DemoRateStartDate",
            "ExecutionTime": "2019-10-24T05:34:56-07:00"
        }
    ],
    "NextToken": "AAEABccwSXqQRGKiTZ1yzGELR6cxW4W/EXAMPLE"
}

유지 관리 기간의 다음 4개 실행에 대한 시작 시간 표시

다음 명령을 실행합니다.

Linux & macOS
aws ssm describe-maintenance-window-schedule \ --window-id "mw-0c50858d01EXAMPLE" \ --max-results "4"
Windows
aws ssm describe-maintenance-window-schedule ^ --window-id "mw-0c50858d01EXAMPLE" ^ --max-results "4"

시스템은 다음과 같은 정보를 반환합니다.

{
    "WindowSchedule": [
        {
            "ScheduledWindowExecutions": [
                {
                    "ExecutionTime": "2019-10-04T10:10:10Z",
                    "Name": "My-First-Maintenance-Window",
                    "WindowId": "mw-0c50858d01EXAMPLE"
                },
                {
                    "ExecutionTime": "2019-10-11T10:10:10Z",
                    "Name": "My-First-Maintenance-Window",
                    "WindowId": "mw-0c50858d01EXAMPLE"
                },
                {
                    "ExecutionTime": "2019-10-18T10:10:10Z",
                    "Name": "My-First-Maintenance-Window",
                    "WindowId": "mw-0c50858d01EXAMPLE"
                },
                {
                    "ExecutionTime": "2019-10-25T10:10:10Z",
                    "Name": "My-First-Maintenance-Window",
                    "WindowId": "mw-0c50858d01EXAMPLE"
                }
            ]
        }
    ]
}