手动创建 OpsItems(PowerShell) - Amazon Systems Manager
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

手动创建 OpsItems(PowerShell)

以下过程介绍了如何使用 Amazon Tools for Windows PowerShell 创建 OpsItem。

使用 Amazon Tools for Windows PowerShell 创建 OpsItem
  1. 打开 Amazon Tools for Windows PowerShell,然后运行以下命令,以指定您的凭证。

    Set-AWSCredentials –AccessKey key-name –SecretKey key-name
  2. 运行以下命令,以便为 PowerShell 会话设置 Amazon Web Services 区域。

    Set-DefaultAWSRegion -Region Region
  3. 运行以下命令以创建新的 OpsItem。将每个示例资源占位符替换为您自己的信息。此命令指定用于修正此 OpsItem 的 Systems Manager 自动化运行手册。

    $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 Amazon_service ` -OperationalData $newHash

    如果成功,此命令将输出新 OpsItem 的 ID。

下面的示例指定了受损的 Amazon Elastic Compute Cloud(Amazon EC2)实例的 Amazon 资源名称(ARN)。

$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