Creación de OpsItems manualmente (AWS CLI) - AWS Systems Manager

Creación de OpsItems manualmente (AWS CLI)

En el siguiente procedimiento se describe cómo se crea un OpsItem con AWS Command Line Interface (AWS CLI).

Para crear un OpsItem mediante la AWS CLI
  1. Si aún no lo ha hecho, instale y configure la AWS Command Line Interface (AWS CLI).

    Para obtener más información, consulte Instalación o actualización de la última versión de la AWS CLI.

  2. Abra la AWS CLI y ejecute el siguiente comando para crear un OpsItem. Reemplace cada example resource placeholder con su propia información.

    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"

    Especificar los datos operativos de un archivo

    Al crear un OpsItem, puede especificar los datos operativos de un archivo. El archivo debe ser un archivo JSON y su contenido debe tener el siguiente formato.

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

    A continuación se muestra un ejemplo.

    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

    Para obtener información acerca de cómo se ingresan los parámetros con formato JSON en la línea de comandos en diferentes sistemas operativos locales, consulte Uso de comillas con cadenas en AWS CLI en la Guía del usuario de AWS Command Line Interface.

    El sistema devuelve información similar a la siguiente.

    {
        "OpsItemId": "oi-1a2b3c4d5e6f"
    }
  3. Ahora ejecute el siguiente comando para ver detalles sobre el OpsItem que ha creado.

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

    El sistema devuelve información similar a la siguiente.

    {
        "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. Ejecute el siguiente comando para actualizar el OpsItem. Este comando cambia el estado de Open (valor predeterminado) a InProgress.

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

    El comando no genera ningún resultado.

  5. Ejecute el siguiente comando de nuevo para comprobar que el estado cambia a InProgress.

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

Ejemplos de creación de un OpsItem

En los siguientes ejemplos de código se muestra cómo crear un OpsItem mediante el portal de administración de Linux, macOS o Windows.

Portal de administración de Linux o macOS

El siguiente comando crea un OpsItem cuando un disco de instancia de Amazon Elastic Compute Cloud (Amazon EC2) está lleno.

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"

El comando siguiente utiliza la clave /aws/resources en OperationalData para crear un OpsItem con un recurso relacionado de 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"

El siguiente comando utiliza la clave /aws/automations en OperationalData para crear un OpsItem que especifique el documento AWS-ASGEnterStandby como manual de procedimientos de Automatización asociado.

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

El siguiente comando crea un OpsItem cuando una instancia de Amazon Relational Database Service (Amazon RDS) no responde.

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"

El comando siguiente utiliza la clave /aws/resources en OperationalData para crear un OpsItem con un recurso relacionado con la instancia de Amazon EC2.

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\"}}

El siguiente comando utiliza la clave /aws/automations en OperationalData para crear un OpsItem que especifique el manual de procedimientos AWS-RestartEC2Instance como manual de procedimientos de Automatización asociado.

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\"}}