Skip to content

How do I find deprecated AMIs in Amazon EC2?

3 minute read
0

I want to find deprecated Amazon Machine Images (AMIs) so that I don’t use them in my Amazon Elastic Compute Cloud (Amazon EC2) instances.

Short description

AWS periodically deprecates public AMIs to encourage the use of up-to-date images with the latest security updates and software versions. However, you can still use deprecated AMIs to launch instances. Use the following best practices to identify and avoid deprecated AMIs.

Resolution

Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.

Find deprecated AMIs

By default, deprecated AMIs don't appear in AMI listings in the Amazon EC2 console. You can only find deprecated AMIs when you run the describe-images AWS CLI command with parameters. To see information about a deprecated AMI, you must include the AMI ID when you run the describe-images. Example command:

aws ec2 describe-images --image-ids ami-example --region us-west-2

Note: Replace ami-example with your AMI ID, and us-west-2 with your AWS Region.

Example output:

{
    "Images": [
        {
            ...
            "DeprecationTime": "2024-06-19T02:23:00.000Z",
            ...
        }
    ]
}

If you must launch an EC2 instance from a deprecated AMI, then run the following run-instances command with the image-id parameter:

aws ec2 run-instances --image-id ami-0a70b9d193ae8a799 --count 1 --instance-type t2.micro --key-name MyKeyPair --region us-west-2

Note: Replace ami-0a70b9d193ae8a799 with your AMI ID, t2.micro with your instance type, MyKeyPair with your key pair, and us-west-2 with your Region. The AMI must be in the Available state.

If you know the ID of a deprecated AMI, you can continue to launch instances with that AMI with the AWS CLI, API, or AWS SDKs. Launch services, such as launch templates and Amazon EC2 Auto Scaling groups, can continue to reference deprecated AMIs. EC2 instances that you launched with an AMI that is later deprecated aren't affected. You can stop, start, and reboot these instances.

You can also get a full list of AMIs owned by a public AMI provider. The following example command lists all the active and deprecated Red Hat Enterprise Linux (RHEL) 6 AMIs owned by Red Hat:

 % aws ec2 describe-images --owners 309956199498 --query 'sort_by(Images, &Name)[*].[CreationDate,DeprecationTime,Name,ImageId]' --filters "Name=name,Values=RHEL-6*" --include-deprecated --region us-east-1 --output table

Note: The preceding command requires the AWS account ID of account that owns the AMIs. It also includes the AMI creation date and deprecation date. You can change the value for owners and for Values to check different owners and OS versions, such as RHEL-7*, RHEL-8*, or RHEL-SAP-9*.

Example output:

|  DescribeImages  |
+--------------------------+---------------------------+-------------------------------------------------------+-------------------------+
| 2013-05-17T20:44:27.000Z| 2022-08-28T23:59:59.000Z | RHEL-6.0_GA-i386-6-Hourly2  | ami-7768011e  |
| 2013-05-17T20:51:32.000Z| 2022-08-28T23:59:59.000Z | RHEL-6.0_GA-x86_64-6-Hourly2  | ami-09680160  |
| 2019-05-29T15:08:15.000Z| 2022-08-28T23:59:59.000Z | RHEL-6.10_HVM-20190524-x86_64-0-Hourly2-GP2 | ami-059897226432ec347 |
| 2019-06-26T15:58:33.000Z| 2022-08-28T23:59:59.000Z | RHEL-6.10_HVM-20190621-x86_64-2-Hourly2-GP2 | ami-0351faf7328fdb373 |
| 2019-09-23T17:35:54.000Z| 2022-08-28T23:59:59.000Z | RHEL-6.10_HVM-20190923-x86_64-1-Hourly2-GP2 | ami-078894980306f5eab |
| 2021-03-18T14:30:58.000Z| 2023-03-18T14:30:58.000Z | RHEL-6.10_HVM-20210318-x86_64-0-Hourly2-GP2 | ami-0a47672f6c7827dd2 |
| 2018-04-19T18:55:59.000Z| 2022-08-28T23:59:59.000Z | RHEL-6.10_HVM_Beta-20180418-x86_64-1-Hourly2-GP2  | ami-f8258987  |
| 2018-06-06T21:58:15.000Z| 2022-08-28T23:59:59.000Z | RHEL-6.10_HVM_GA-20180606-x86_64-1-Hourly2-GP2  | ami-6d176b12  |
| 2018-08-11T01:14:36.000Z| 2022-08-28T23:59:59.000Z | RHEL-6.10_HVM_GA-20180810-x86_64-0-Hourly2-GP2  | ami-0b1d4c689c7949a64 |

Related information

Deprecate an Amazon EC2 AMI

Deregister an Amazon EC2 AMI

AWS OFFICIALUpdated 22 days ago