手动创建 OpsItems(PowerShell) - AWS Systems Manager

AWS Systems Manager Change Manager 不再向新客户开放。现有客户可以继续正常使用该服务。有关更多信息,请参阅 AWS Systems Manager Change Manager 可用性变更

手动创建 OpsItems(PowerShell)

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

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

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

    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 AWS_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