Skip to content

Instantly share code, notes, and snippets.

"""
Original Code was adapted from https://github.com/miztiik/serverless-janitor-for-ami/blob/master/serverless-janitor-for-ami.py
Modified to give JSON report responses with information about the instance and the exact number images being deleted with their
ami-image id.
Make sure to include the AmiBackUp key with true as a value so that the script can track the instance for you.
"""
import boto3
import collections
import datetime
@SixthTitan
SixthTitan / ami_delete.py
Last active July 11, 2021 23:55
EC2 AMI Deletion with Report and Snapshot Deletion
"""
Original Code was adapted from https://github.com/miztiik/serverless-janitor-for-ami/blob/master/serverless-janitor-for-ami.py
Modified to give JSON report responses with information about the instance and the exact number images being deleted with their
ami-image id.
Make sure to include the AmiBackUp key with true as a value so that the script can track the instance for you.
"""
import os
import re