12345678910111213141516171819202122 |
- #! /bin/bash
- #
- # Requires amicleaner:
- # ```
- # pip3 install aws-amicleaner
- # ```
- VERSIONS_TO_KEEP=3
- for profile in mdr-common-services-gov mdr-common-services; do
- echo
- echo ==== Cleaning $profile
- echo
- AWS_PROFILE=${profile} amicleaner --full-report --keep-previous ${VERSIONS_TO_KEEP} --mapping-key tags --mapping-values Description Release --check-orphans
- echo =========== Done
- echo
- done
- echo
- echo AMIs listed under \'no-tags\' were likely orphaned by packer via ctrl-c. Clean them up via:
- echo \ \ aws ec2 deregister-image --image-id ami-xxxxxxx --profile mdr-common-services-gov
- echo and then rerun $0
- echo
|