Skip to content

Instantly share code, notes, and snippets.

@Yehonal
Created July 25, 2024 14:56
Show Gist options
  • Save Yehonal/9ce5a1fd7f8b5417cc7e511b3f292b68 to your computer and use it in GitHub Desktop.
Save Yehonal/9ce5a1fd7f8b5417cc7e511b3f292b68 to your computer and use it in GitHub Desktop.
How to close AWS incidents in bulk
#!/bin/bash
# Set the AWS region
REGION="eu-west-1"
PROFILE="your-aws-cli-profile"
aws ssm-incidents list-incident-records --region $REGION --profile $PROFILE | jq -r '.incidentRecordSummaries[] | select(.status != "RESOLVED") | .arn' >incident_ids.txt
while read incident_id; do
aws ssm-incidents update-incident-record --region $REGION --arn $incident_id --status "RESOLVED" --profile $PROFILE
echo "Incident $incident_id has been closed."
done <incident_ids.txt
echo "All unresolved incidents have been closed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment