View a markdown version of this page

Création manuelle d'OpsItems (PowerShell) - AWS Systems Manager

Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.

Création manuelle d'OpsItems (PowerShell)

La procédure suivante décrit comment créer un OpsItem à l'aide de AWS Tools for Windows PowerShell.

Pour créer une OpsItem utilisation AWS Tools for Windows PowerShell
  1. Ouvrez AWS Tools for Windows PowerShell et exécutez la commande suivante pour spécifier vos informations d'identification.

    Set-AWSCredentials –AccessKey key-name –SecretKey key-name
  2. Exécutez la commande suivante pour définir le Région AWS pour votre PowerShell session.

    Set-DefaultAWSRegion -Region Region
  3. Exécutez la commande suivante pour créer un nouveau OpsItem. Remplacez chaque example resource placeholder par vos propres informations. Cette commande spécifie un runbook Systems Manager Automation pour corriger cet OpsItem.

    $opsItem = New-Object Amazon.SimpleSystemsManagement.Model.OpsItemDataValue $opsItem.Type = [Amazon.SimpleSystemsManagement.OpsItemDataType]::SearchableString $opsItem.Value = '[{\"automationId\":\"runbook_name\",\"automationType\":\"AWS::SSM::Automation\"}]' $newHash = @{" /aws/automations"=[Amazon.SimpleSystemsManagement.Model.OpsItemDataValue]$opsItem} New-SSMOpsItem ` -Title "title" ` -Description "description" ` -Priority priority_number ` -Source AWS_service ` -OperationalData $newHash

    En cas de réussite, la commande génère l'ID du nouveau OpsItem.

L'exemple suivant spécifie l'Amazon Resource Name (ARN) d'une instance Amazon Elastic Compute Cloud (Amazon EC2).

$opsItem = New-Object Amazon.SimpleSystemsManagement.Model.OpsItemDataValue $opsItem.Type = [Amazon.SimpleSystemsManagement.OpsItemDataType]::SearchableString $opsItem.Value = '[{\"arn\":\"arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0\"}]' $newHash = @{" /aws/resources"=[Amazon.SimpleSystemsManagement.Model.OpsItemDataValue]$opsItem} New-SSMOpsItem -Title "EC2 instance disk full still" -Description "Log clean up may have failed which caused the disk to be full" -Priority 2 -Source ec2 -OperationalData $newHash