Creazione manuale di OpsItems (AWS CLI) - AWS Systems Manager

AWS Systems ManagerChange Managernon è più aperto a nuovi clienti. I clienti esistenti possono continuare a utilizzare il servizio normalmente. Per ulteriori informazioni, consulta AWS Systems ManagerChange Managerla pagina Modifica della disponibilità.

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Creazione manuale di OpsItems (AWS CLI)

Nella procedura riportata di seguito viene descritto come creare un OpsItem tramite AWS Command Line Interface (AWS CLI).

Per creare un file OpsItem utilizzando AWS CLI
  1. Installa e configura AWS Command Line Interface (AWS CLI), se non l'hai già fatto.

    Per informazioni, consulta la pagina Installazione o aggiornamento della versione più recente di AWS CLI.

  2. Apri AWS CLI ed esegui il seguente comando per creare unOpsItem. Sostituisci ogni example resource placeholder con le tue informazioni.

    aws ssm create-ops-item \ --title "Descriptive_title" \ --description "Information_about_the_issue" \ --priority Number_between_1_and_5 \ --source Source_of_the_issue \ --operational-data Up_to_20_KB_of_data_or_path_to_JSON_file \ --notifications Arn="SNS_ARN_in_same_Region" \ --tags "Key=key_name,Value=a_value"

    Specificare i dati operativi da un file

    Quando crei un OpsItem, è possibile specificare i dati operativi da un file. Il file deve essere un file JSON e i contenuti del file devono avere il formato seguente.

    { "key_name": { "Type": "SearchableString", "Value": "Up to 20 KB of data" } }

    Ecco un esempio.

    aws ssm create-ops-item ^ --title "EC2 instance disk full" ^ --description "Log clean up may have failed which caused the disk to be full" ^ --priority 2 ^ --source ec2 ^ --operational-data file:///Users/TestUser1/Desktop/OpsItems/opsData.json ^ --notifications Arn="arn:aws:sns:us-west-1:12345678:TestUser1" ^ --tags "Key=EC2,Value=Production"
    Nota

    Per informazioni su come immettere parametri in formato JSON sulla riga di comando in diversi sistemi operativi locali, consulta Utilizzo di virgolette con stringhe AWS CLI nella Guida per l'utente di AWS Command Line Interface .

    Il sistema restituisce informazioni simili alle seguenti.

    {
        "OpsItemId": "oi-1a2b3c4d5e6f"
    }
  3. Esegui questo comando per visualizzare i dettagli sull'OpsItem che hai creato.

    aws ssm get-ops-item --ops-item-id ID

    Il sistema restituisce informazioni simili alle seguenti.

    {
        "OpsItem": {
            "CreatedBy": "arn:aws:iam::12345678:user/TestUser",
            "CreatedTime": 1558386334.995,
            "Description": "Log clean up may have failed which caused the disk to be full",
            "LastModifiedBy": "arn:aws:iam::12345678:user/TestUser",
            "LastModifiedTime": 1558386334.995,
            "Notifications": [
                {
                    "Arn": "arn:aws:sns:us-west-1:12345678:TestUser"
                }
            ],
            "Priority": 2,
            "RelatedOpsItems": [],
            "Status": "Open",
            "OpsItemId": "oi-1a2b3c4d5e6f",
            "Title": "EC2 instance disk full",
            "Source": "ec2",
            "OperationalData": {
                "EC2": {
                    "Value": "12345",
                    "Type": "SearchableString"
                }
            }
        }
    }
  4. Eseguire il seguente comando per aggiornare OpsItem. Questo comando modifica lo stato da Open (predefinito) a InProgress.

    aws ssm update-ops-item --ops-item-id ID --status InProgress

    Il comando non ha output.

  5. Esegui nuovamente il seguente comando per verificare che lo stato sia cambiato in InProgress.

    aws ssm get-ops-item --ops-item-id ID

Esempi di creazione di un OpsItem

Negli esempi seguenti viene illustrato come creare un OpsItem utilizzando il portale di gestione Linux, macOS oppure Windows Server.

Portale di gestione Linux oppure macOS

Il comando seguente crea un messaggio OpsItem quando un disco di istanza Amazon Elastic Compute Cloud (Amazon EC2) è pieno.

aws ssm create-ops-item \ --title "EC2 instance disk full" \ --description "Log clean up may have failed which caused the disk to be full" \ --priority 2 \ --source ec2 \ --operational-data '{"EC2":{"Value":"12345","Type":"SearchableString"}}' \ --notifications Arn="arn:aws:sns:us-west-1:12345678:TestUser1" \ --tags "Key=EC2,Value=ProductionServers"

Il comando seguente utilizza la chiave /aws/resources in OperationalData per creare un OpsItem con una risorsa correlata ad Amazon DynamoDB.

aws ssm create-ops-item \ --title "EC2 instance disk full" \ --description "Log clean up may have failed which caused the disk to be full" \ --priority 2 \ --source ec2 \ --operational-data '{"/aws/resources":{"Value":"[{\"arn\": \"arn:aws:dynamodb:us-west-2:12345678:table/OpsItems\"}]","Type":"SearchableString"}}' \ --notifications Arn="arn:aws:sns:us-west-2:12345678:TestUser"

Il comando seguente utilizza la chiave /aws/automations in OperationalData per creare un OpsItem che specifica il documento AWS-ASGEnterStandby come runbook Automation associato.

aws ssm create-ops-item \ --title "EC2 instance disk full" \ --description "Log clean up may have failed which caused the disk to be full" \ --priority 2 \ --source ec2 \ --operational-data '{"/aws/automations":{"Value":"[{\"automationId\": \"AWS-ASGEnterStandby\", \"automationType\": \"AWS::SSM::Automation\"}]","Type":"SearchableString"}}' \ --notifications Arn="arn:aws:sns:us-west-2:12345678:TestUser"

Windows

Il comando seguente crea un OpsItem quando un'istanza Amazon Relational Database Service (Amazon RDS) non risponde.

aws ssm create-ops-item ^ --title "RDS instance not responding" ^ --description "RDS instance not responding to ping" ^ --priority 1 ^ --source RDS ^ --operational-data={\"RDS\":{\"Value\":\"abcd\",\"Type\":\"SearchableString\"}} ^ --notifications Arn="arn:aws:sns:us-west-1:12345678:TestUser1" ^ --tags "Key=RDS,Value=ProductionServers"

Il comando seguente utilizza la /aws/resources chiave in OperationalData per creare una risorsa relativa OpsItem a un' EC2 istanza Amazon.

aws ssm create-ops-item ^ --title "EC2 instance disk full" ^ --description "Log clean up may have failed which caused the disk to be full" ^ --priority 2 ^ --source ec2 ^ --operational-data={\"/aws/resources\":{\"Value\":\"[{\\"""arn\\""":\\"""arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0\\"""}]\",\"Type\":\"SearchableString\"}}

Il comando seguente utilizza la chiave /aws/automations in OperationalData per creare un OpsItem che specifica il runbook AWS-RestartEC2Instance come runbook Automation associato.

aws ssm create-ops-item ^ --title "EC2 instance disk full" ^ --description "Log clean up may have failed which caused the disk to be full" ^ --priority 2 ^ --source ec2 ^ --operational-data={\"/aws/automations\":{\"Value\":\"[{\\"""automationId\\""":\\"""AWS-RestartEC2Instance\\”"",\\"""automationType\\""":\\"""AWS::SSM::Automation\\"""}]\",\"Type\":\"SearchableString\"}}