Ongoing service disruptions
For the most recent update on ongoing service disruptions affecting the AWS Middle East (UAE) Region (ME-CENTRAL-1), refer to the AWS Health Dashboard. For information on AWS Service migration, see How do I migrate my services to another region?
如何在 Amazon EC2 中尋找已淘汰的 AMI?
我想找出已淘汰的 Amazon Machine Image (AMI),以避免在 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體中使用它們。
簡短描述
AWS 會定期淘汰公有 AMI,以鼓勵使用具有最新安全更新和軟體版本的最新影像檔。但是,您仍然可以使用已淘汰的 AMI 來啟動執行個體。使用以下最佳做法來識別並避免已淘汰的 AMI。
解決方法
**注意:**如果您在執行 AWS Command Line Interface (AWS CLI) 命令時收到錯誤訊息,請參閱對 AWS CLI 錯誤進行疑難排解。此外,請確定您使用的是最新的 AWS CLI 版本。
尋找已淘汰的 AMI
預設情況下,已淘汰的 AMI 不會出現在 Amazon EC2 主控台中的 AMI 清單中。只有當您執行帶有參數的 describe-images AWS CLI 命令時,才能找到已淘汰的 AMI。若要查看已淘汰 AMI 的資訊,您必須在執行 describe-images 時包含 AMI ID。命令範例:
aws ec2 describe-images --image-ids ami-example --region us-west-2
**注意:**將 ami-example 替換為您的 AMI ID,並將 us-west-2 替換為您的 AWS 區域。
輸出範例:
{ "Images": [ { ... "DeprecationTime": "2024-06-19T02:23:00.000Z", ... } ] }
如果您必須從已淘汰的 AMI 啟動 EC2 執行個體,請執行以下帶有 image-id 參數的 run-instances 命令:
aws ec2 run-instances --image-id ami-0a70b9d193ae8a799 --count 1 --instance-type t2.micro --key-name MyKeyPair --region us-west-2
注意:將 ami-0a70b9d193ae8a799 替換為您的 AMI ID,將 t2.micro 替換為您的執行個體類型,將 MyKeyPair 替換為您的金鑰對,並將 us-west-2 替換為您的區域。AMI 必須處於可用狀態。
如果您知道已淘汰 AMI 的 ID,則可以繼續使用 AWS CLI、API 或 AWS SDKs 啟動該 AMI 的執行個體。啟動服務 (例如啟動範本和 Amazon EC2 Auto Scaling 群組) 可以繼續參考已淘汰的 AMI。使用後來淘汰的 AMI 啟動的 EC2 執行個體不會受到影響。您可以停止、啟動和重新啟動這些執行個體。
您還可以獲得公有 AMI 供應商擁有的 AMI 完整清單。以下範例命令列出了 Red Hat 擁有的所有活動和已淘汰的 Red Hat Enterprise Linux (RHEL) 6 AMI:
% 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
**注意:**上述命令需要擁有這些 AMI 的 AWS 帳戶 ID。它還包括 AMI 建立日期和淘汰日期。您可以變更 owners 和 Values 的值,以檢查不同的擁有者和作業系統版本,例如 RHEL-7*、RHEL-8* 或 RHEL-SAP-9*。
輸出範例:
| 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 |
