Creating OpsItems manually (PowerShell)
The following procedure describes how to create an OpsItem by using AWS Tools for Windows PowerShell.
To create an OpsItem using AWS Tools for Windows PowerShell
-
Open AWS Tools for Windows PowerShell and run the following command to specify your credentials.
Set-AWSCredentials –AccessKey
key-name
–SecretKeykey-name
-
Run the following command to set the AWS Region for your PowerShell session.
Set-DefaultAWSRegion -Region
Region
-
Run the following command to create a new OpsItem. Replace each
example resource placeholder
with your own information. This command specifies a Systems Manager Automation runbook for remediating this 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
" ` -Prioritypriority_number
` -SourceAWS_service
` -OperationalData $newHashIf successful, the command outputs the ID of the new OpsItem.
The following example specifies the Amazon Resource Name (ARN) of an impaired Amazon Elastic Compute Cloud (Amazon EC2) instance.
$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