Tutorial: vea información sobre periodos de mantenimiento mediante la AWS CLI
Este tutorial incluye comandos para ayudarle a actualizar u obtener información sobre sus periodos de mantenimiento, tareas, ejecuciones e invocaciones. Los ejemplos están organizados por comando para mostrar cómo utilizar las opciones de comando para filtrar el tipo de detalle que desea ver.
A medida que siga los pasos que se indican en este tutorial, reemplace los valores en rojo y cursiva por sus propias opciones y sus ID. Por ejemplo, reemplace el ID del periodo de mantenimiento mw-0c50858d01EJEMPLO y el ID de la instancia i-02573cafcfEJEMPLO por los ID de los recursos que usted cree.
Para obtener información acerca de la instalación y configuración de AWS Command Line Interface (AWS CLI), consulte Instalación, actualización y desinstalación de AWS CLI y Configuración de AWS CLI.
Ejemplos de comando
Ejemplos de “describe-maintenance-windows”
Enumerar todos los periodos de mantenimiento de su Cuenta de AWS
Ejecute el siguiente comando.
aws ssm describe-maintenance-windows
El sistema devuelve información similar a la siguiente.
{ "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" }, ] }
Enumerar todos los períodos de mantenimiento habilitados
Ejecute el siguiente comando.
aws ssm describe-maintenance-windows --filters "Key=Enabled,Values=true"
El sistema devuelve información similar a la siguiente.
{ "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" }, ] }
Enumerar todos los períodos de mantenimiento deshabilitados
Ejecute el siguiente comando.
aws ssm describe-maintenance-windows --filters "Key=Enabled,Values=false"
El sistema devuelve información similar a la siguiente.
{ "WindowIdentities": [ { "WindowId": "mw-6e5c9d4b7cEXAMPLE", "Name": "My-Disabled-Maintenance-Window", "Enabled": false, "Duration": 2, "Cutoff": 1 } ] }
Enumerar todos los periodos de mantenimiento que tienen nombres que comienzan por un prefijo determinado
Ejecute el siguiente comando.
aws ssm describe-maintenance-windows --filters "Key=Name,Values=My"
El sistema devuelve información similar a la siguiente.
{ "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 } ] }
Ejemplos de “describe-maintenance-window-targets”
Mostrar los destinos de un período de mantenimiento que coincida con un valor específico de información del propietario
Ejecute el siguiente comando.
nota
Las claves de filtro admitidas son Type, WindowTargetId y OwnerInformation.
El sistema devuelve información similar a la siguiente.
{ "Targets": [ { "WindowId": "mw-0c50858d01EXAMPLE", "WindowTargetId": "e32eecb2-646c-4f4b-8ed1-205fbEXAMPLE", "ResourceType": "INSTANCE", "Targets": [ { "Key": "tag:Name", "Values": [ "Production" ] } ], "OwnerInformation": "CostCenter1", "Name": "Target1" } ] }
Ejemplos de “describe-maintenance-window-tasks”
Mostrar todas las tareas registradas que invoquen el documento de Command de SSM AWS-RunPowerShellScript
Ejecute el siguiente comando.
El sistema devuelve información similar a la siguiente.
{ "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" } ] } ] }
Visualización de todas las tareas registradas que tengan una prioridad de "3"
Ejecute el siguiente comando.
El sistema devuelve información similar a la siguiente.
{ "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" } ] } ] }
Mostrar todas las tareas registradas que tengan una prioridad de "1" y usar Run Command
Ejecute el siguiente comando.
El sistema devuelve información similar a la siguiente.
{ "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" } ] }
Ejemplos de “describe-maintenance-windows-for-target”
Mostrar información acerca de los destinos de periodo de mantenimiento o las tareas asociadas con un nodo específico
Ejecute el siguiente comando.
El sistema devuelve información similar a la siguiente.
{ "WindowIdentities": [ { "WindowId": "mw-0c50858d01EXAMPLE", "Name": "My-First-Maintenance-Window" }, { "WindowId": "mw-9a8b7c6d5eEXAMPLE", "Name": "My-Second-Maintenance-Window" } ] }
Ejemplos de “describe-maintenance-window-executions”
Enumerar todas las tareas ejecutadas antes de una fecha determinada
Ejecute el siguiente comando.
El sistema devuelve información similar a la siguiente.
{ "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 } ] }
Enumerar todas las tareas ejecutadas después de una fecha determinada
Ejecute el siguiente comando.
El sistema devuelve información similar a la siguiente.
{ "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 } ] }
Ejemplos de “describe-maintenance-window-schedule”
Mostrar las próximas diez ejecuciones programadas de periodo de mantenimiento para un nodo determinado
Ejecute el siguiente comando.
El sistema devuelve información similar a la siguiente.
{ "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" }
Mostrar el programa de periodo de mantenimiento para los nodos etiquetados con un determinado par clave-valor
Ejecute el siguiente comando.
El sistema devuelve información similar a la siguiente.
{ "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" }
Mostrar las horas de inicio para las cuatro siguientes ejecuciones de un periodo de mantenimiento
Ejecute el siguiente comando.
El sistema devuelve información similar a la siguiente.
{ "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" } ] } ] }