チュートリアル: 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' の例
特定の所有者情報の値に一致するメンテナンスウィンドウのターゲットを表示する
次のコマンドを実行します。
注記
サポートされているフィルタキーは Type
、WindowTargetId
、OwnerInformation
です。
システムは以下のような情報を返します。
{ "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
を呼び出す登録されたタスクをすべて表示する
次のコマンドを実行します。
システムは以下のような情報を返します。
{ "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" の登録されたタスクをすべて表示する
次のコマンドを実行します。
システムは以下のような情報を返します。
{ "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 を使用するすべての登録されたタスクを表示する
以下のコマンドを実行します。
システムは以下のような情報を返します。
{ "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」の例
特定のノードに関連付けられたメンテナンスウィンドウターゲットまたはタスクに関する情報を一覧表示する
以下のコマンドを実行します。
システムは以下のような情報を返します。
{ "WindowIdentities": [ { "WindowId": "mw-0c50858d01EXAMPLE", "Name": "My-First-Maintenance-Window" }, { "WindowId": "mw-9a8b7c6d5eEXAMPLE", "Name": "My-Second-Maintenance-Window" } ] }
'describe-maintenance-window-executions'
特定の日付の前に実行されたタスクを一覧表示する
次のコマンドを実行します。
システムは以下のような情報を返します。
{ "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 } ] }
特定の日付の後で実行されるすべてのタスクを一覧表示する
次のコマンドを実行します。
システムは以下のような情報を返します。
{ "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 個のスケジュールされたメンテナンスウィンドウを表示する
以下のコマンドを実行します。
システムは以下のような情報を返します。
{ "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" }
特定のキーと値のペアでタグ付けされたノードのメンテナンスウィンドウのスケジュールを表示する
以下のコマンドを実行します。
システムは以下のような情報を返します。
{ "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 つの開始時間を表示し、メンテナンスウィンドウの実行
次のコマンドを実行します。
システムは以下のような情報を返します。
{ "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" } ] } ] }