I want to automatically manage Amazon Machine Images (AMIs) of my Amazon Elastic Compute Cloud (Amazon EC2) instances.
Short description
To manage AMIs, it's a best practice to use an automated solution instead of manual management. Automated AMI management helps you create AMIs on a regular schedule, automatically delete old AMIs based on retention policies, and protect against accidental deletion. Manual management can cause you to accidentally accumulate many AMIs and increase your storage costs. You might also accidentally delete an AMI that you still require.
To automatically manage your AMIs, use one or more of the following solutions:
- Automate AMI creation and deletion with Amazon Data Lifecycle Manager.
- Automate AMI backups with AWS Backup.
- Protect against accidental AMI deletion with Recycle Bin.
Resolution
Automate AMI creation and deletion with Amazon Data Lifecycle Manager
You can configure Amazon Data Lifecycle Manager to create AMIs on a custom schedule and deletes AMIs that exceed your retention period. To create a lifecycle policy for AMIs, see Create an AMI lifecycle policy.
Automate AMI backups with AWS Backup
AWS Backup provides centralized backup management for EC2 instances. You can create backup plans that automatically create AMIs on a schedule and manage their lifecycle.
For more information, see Amazon EC2 backup and recovery with snapshots and AMIs.
Protect against accidental AMI deletion with Recycle Bin
Recycle Bin retains deleted AMIs for a specified period before it permanently deletes the AMIs. It's a best practice to create a Recycle Bin retention rule to define how long Recycle Bin keeps the AMIs to prevent accidental deletion.
If you accidentally delete an AMI, then you can restore it from Recycle Bin. For more information, see How do I recover an accidentally deleted AMI?