Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Deregister your AMI
You can deregister an AMI when you have finished using it. After you deregister an AMI, you
can't use it to launch new instances.
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.
Considerations
The following considerations apply to deregistering AMIs:
-
You can't deregister an AMI that is not owned by your account.
-
You can't deregister an AMI that is managed by the Amazon Backup service using Amazon EC2.
Instead, use Amazon Backup to delete the corresponding recovery points in the backup vault. For
more information, see Deleting backups in the Amazon Backup Developer
Guide.
Clean up your AMI
When you deregister an AMI, it doesn't affect the snapshot(s) that were
created for the volume(s) of the instance during the AMI creation process. You'll continue to
incur storage costs for the snapshots. Therefore, if you are finished with the snapshots, you
should delete them.
The following diagram illustrates the process for cleaning up your
AMI.
You can use one of the following methods to clean up your AMI.
- New console
-
To clean up your AMI
Open the Amazon EC2 console at
https://console.amazonaws.cn/ec2/.
-
Deregister the AMI
-
In the navigation pane, choose AMIs.
-
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.
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.
- Old console
-
To clean up your AMI
Open the Amazon EC2 console at
https://console.amazonaws.cn/ec2/.
-
Deregister the AMI
-
In the navigation pane, choose AMIs.
-
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. When
prompted for confirmation, choose Continue.
It may 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. When
prompted for confirmation, choose Yes, 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 Actions, Instance State,
Terminate. When prompted for confirmation, choose
Yes, Terminate.
- Amazon CLI
-
Follow these steps to clean up your AMI
-
Deregister the AMI
Deregister the AMI using the deregister-image command:
aws ec2 deregister-image --image-id ami-12345678
-
Delete snapshots that are no longer needed
Delete snapshots that are no longer needed by using the delete-snapshot
command:
aws ec2 delete-snapshot --snapshot-id snap-1234567890abcdef0
-
Terminate instances (Optional)
If you are finished with an instance that you launched from the AMI, you can
terminate it by using the terminate-instances command:
aws ec2 terminate-instances --instance-ids i-12345678
- PowerShell
-
Follow these steps to clean up your AMI
-
Deregister the AMI
Deregister the AMI using the Unregister-EC2Image
cmdlet:
Unregister-EC2Image -ImageId ami-12345678
-
Delete snapshots that are no longer needed
Delete snapshots that are no longer needed by using the Remove-EC2Snapshot
cmdlet:
Remove-EC2Snapshot -SnapshotId snap-12345678
-
Terminate instances (Optional)
If you are finished with an instance that you launched from the AMI, you can
terminate it by using the Remove-EC2Instance cmdlet:
Remove-EC2Instance -InstanceId i-12345678
Last launched time
LastLaunchedTime
is a timestamp that indicates when your AMI was last used to
launch an instance. AMIs that have not been used recently to launch an instance might be good
candidates for deregistering or deprecation.
-
When the AMI is used to launch an instance, there is a 24-hour delay before that
usage is reported.
-
lastLaunchedTime
data is available starting April 2017.
- Console
-
To view the last launched time of an AMI
-
Open the Amazon EC2 console at
https://console.amazonaws.cn/ec2/.
-
In the left navigator, choose AMIs.
-
From the filter bar, choose Owned by
me.
-
Select the AMI, and then check the Last launched
time field (if you selected the check box next to
the AMI, it's located on the Details tab).
The field shows the date and time when the AMI was last used to
launch an instance.
- Amazon CLI
-
To view the last launched time of an AMI
Run the describe-image-attribute command and specify --attribute
lastLaunchedTime
. You must be the AMI owner to run this command.
aws ec2 describe-image-attribute \
--image-id ami-1234567890example
\
--attribute lastLaunchedTime
Example output
{
"LastLaunchedTime": {
"Value": "2022-02-10T02:03:18Z"
},
"ImageId": "ami-1234567890example",
}