Plugin Title | Outdated Amazon Machine Images |
Cloud | AWS |
Category | EC2 |
Description | Ensures that deprecated Amazon Machine Images are not in use. |
More Info | Deprecated Amazon Machine Images should not be used to make an instance. |
AWS Link | https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ami-deprecate.html |
Recommended Action | Delete the instances using deprecated AMIs |
To delete the AMI so that users and services cannot use it, you must deregister it
When you deregister an AMI, it doesn't affect any instances that you've already launched from the AMI or any snapshots created during the AMI creation process. You'll continue to incur usage costs for these instances and storage costs for the snapshot. Therefore, you should terminate any instances and delete any snapshots that you're finished with.
The procedure that you'll use to clean up your AMI depends on whether it's backed by Amazon EBS or instance store. For more information, see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ComponentsAMIs.html#display-ami-root-device-type
To clean up your Amazon EBS-backed AMI.
- Log into the AWS Management Console.
- Select the "Services" option and search for EC2.
- In the navigation pane, choose AMIs.
4.Select the AMI to deregister, and take note of its ID—this can help you find the snapshots to delete in the next step. - Choose Actions, Deregister AMI. When prompted for confirmation, choose Deregister AMI.
Note: It might take a few minutes before the console removes the AMI from the list. Choose Refresh to refresh the status.
Delete snapshots that are no longer needed. - In the navigation pane, choose Snapshots.
- Select a snapshot to delete (look for the AMI ID from the prior step in the Description column).
- Choose Actions, Delete snapshot. When prompted for confirmation, choose Delete.
(Optional) Terminate instances
- If you are finished with an instance that you launched from the AMI, you can terminate it.
- In the navigation pane, choose Instances, and then select the instance to terminate.
- Choose Instance state, Terminate instance. When prompted for confirmation, choose Terminate.
Clean up your instance store-backed AMI
- Deregister the AMI using the deregister-image command as follows.
aws ec2 deregister-image --image-id ami_id - Delete the bundle in Amazon S3 using the ec2-delete-bundle (AMI tools) command as follows.
ec2-delete-bundle -b myawsbucket/myami -a your_access_key_id -s your_secret_access_key -p image - (Optional) If you are finished with an instance that you launched from the AMI, you can terminate it using the terminate-instances command as follows.
aws ec2 terminate-instances --instance-ids instance_id - (Optional) If you are finished with the Amazon S3 bucket that you uploaded the bundle to, you can delete the bucket. To delete an Amazon S3 bucket, open the Amazon S3 console, select the bucket, choose Actions, and then choose Delete.