呼叫 AMI 公有參數 - AWS Systems Manager

呼叫 AMI 公有參數

在以下路徑中,Amazon Elastic Compute Cloud (Amazon EC2) Amazon Machine Image (AMI) 公有參數可用於 Amazon Linux、Amazon Linux 2 以及 Windows Server:

  • Amazon Linux 和 Amazon Linux 2:/aws/service/ami-amazon-linux-latest

  • Windows Server: /aws/service/ami-windows-latest

呼叫 Amazon Linux 和 Amazon Linux 2 的 AMI 公有參數。

您可以在 AWS Command Line Interface (AWS CLI) 中使用以下命令檢視目前 AWS 區域 中所有 Amazon Linux 和 Amazon Linux 2 AMIs 的清單。

Linux & macOS
aws ssm get-parameters-by-path \ --path /aws/service/ami-amazon-linux-latest \ --query 'Parameters[].Name'
Windows
aws ssm get-parameters-by-path ^ --path /aws/service/ami-amazon-linux-latest ^ --query Parameters[].Name

該命令會傳回相關資訊,如以下所示。

[
    "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-ebs",
    "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2",
    "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-s3",
    "/aws/service/ami-amazon-linux-latest/amzn-ami-minimal-hvm-x86_64-s3",
    "/aws/service/ami-amazon-linux-latest/amzn-ami-minimal-pv-x86_64-s3",
    "/aws/service/ami-amazon-linux-latest/amzn-ami-pv-x86_64-s3",
    "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-arm64-gp2",
    "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-ebs",
    "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2",
    "/aws/service/ami-amazon-linux-latest/amzn2-ami-minimal-hvm-arm64-ebs",
    "/aws/service/ami-amazon-linux-latest/amzn-ami-minimal-hvm-x86_64-ebs",
    "/aws/service/ami-amazon-linux-latest/amzn-ami-minimal-pv-x86_64-ebs",
    "/aws/service/ami-amazon-linux-latest/amzn-ami-pv-x86_64-ebs",
    "/aws/service/ami-amazon-linux-latest/amzn2-ami-minimal-hvm-x86_64-ebs"
]

您可以使用以下命令檢視這些 AMIs 的詳細資訊,包括 AMI ID 和 Amazon Resource Name (ARN)。

Linux & macOS
aws ssm get-parameters-by-path \ --path "/aws/service/ami-amazon-linux-latest" \ --region region
Windows
aws ssm get-parameters-by-path ^ --path "/aws/service/ami-amazon-linux-latest" ^ --region region

region 代表 AWS Systems Manager 支援之 AWS 區域 的識別符,例如 us-east-2 代表美國東部 (俄亥俄) 區域。如需 region 值的清單,請參閱《Amazon Web Services 一般參考》中 Systems Manager 服務端點中的 Region (區域) 資料欄。

該命令會傳回相關資訊,如以下所示。此範例輸出因空間不足已被截斷。

{
    "Parameters": [
        {
            "Name": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-ebs",
            "Type": "String",
            "Value": "ami-02f31e7644d23a001",
            "Version": 32,
            "LastModifiedDate": "2021-10-04T14:51:40.313000-07:00",
            "ARN": "arn:aws:ssm:us-east-2::parameter/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-ebs",
            "DataType": "text"
        },
        {
            "Name": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2",
            "Type": "String",
            "Value": "ami-0a787ac2e0c399e8b",
            "Version": 32,
            "LastModifiedDate": "2021-10-04T14:51:40.424000-07:00",
            "ARN": "arn:aws:ssm:us-east-2::parameter/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2",
            "DataType": "text"
        },
        {
            "Name": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-s3",
            "Type": "String",
            "Value": "ami-0437136c909273ff3",
            "Version": 32,
            "LastModifiedDate": "2021-10-04T14:51:40.533000-07:00",
            "ARN": "arn:aws:ssm:us-east-2::parameter/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-s3",
            "DataType": "text"
        }
    ]
}

您可以使用 GetParameters API 操作及完整 AMI 名稱 (包括路徑) 檢視特定 AMI 的詳細資訊。以下為範例命令。

Linux & macOS
aws ssm get-parameters \ --names /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2 \ --region us-east-2
Windows
aws ssm get-parameters ^ --names /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2 ^ --region us-east-2

此命令會傳回以下資訊。

{
    "Parameters": [
        {
            "Name": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2",
            "Type": "String",
            "Value": "ami-074cce78125f09d61",
            "Version": 51,
            "LastModifiedDate": "2021-10-06T16:50:43.294000-07:00",
            "ARN": "arn:aws:ssm:us-east-2::parameter/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2",
            "DataType": "text"
        }
    ],
    "InvalidParameters": []
}

呼叫 Windows Server 的 AMI 公有參數

您可以在 AWS CLI 中使用以下命令檢視目前 AWS 區域 中所有 Windows Server AMIs 的清單。

Linux & macOS
aws ssm get-parameters-by-path \ --path /aws/service/ami-windows-latest \ --query 'Parameters[].Name'
Windows
aws ssm get-parameters-by-path ^ --path /aws/service/ami-windows-latest ^ --query Parameters[].Name

該命令會傳回相關資訊,如以下所示。此範例輸出因空間不足已被截斷。

[
    "/aws/service/ami-windows-latest/Windows_Server-2012-R2_RTM-Chinese_Simplified-64Bit-Base",
    "/aws/service/ami-windows-latest/Windows_Server-2012-R2_RTM-Chinese_Traditional-64Bit-Base",
    "/aws/service/ami-windows-latest/Windows_Server-2012-R2_RTM-Dutch-64Bit-Base",
    "/aws/service/ami-windows-latest/Windows_Server-2012-R2_RTM-Hungarian-64Bit-Base",
    "/aws/service/ami-windows-latest/Windows_Server-2012-R2_RTM-Japanese-64Bit-Base",
    "/aws/service/ami-windows-latest/Windows_Server-2016-English-Core-Containers",
    "/aws/service/ami-windows-latest/Windows_Server-2016-German-Full-Base",
    "/aws/service/ami-windows-latest/Windows_Server-2016-Japanese-Full-SQL_2017_Web",
    "/aws/service/ami-windows-latest/Windows_Server-2019-English-Core-EKS_Optimized-1.17",
    "/aws/service/ami-windows-latest/amzn2-ami-hvm-2.0.20191217.0-x86_64-gp2-mono",
    "/aws/service/ami-windows-latest/Windows_Server-2012-R2_RTM-English-64Bit-SQL_2016_SP2_Standard",
    "/aws/service/ami-windows-latest/Windows_Server-2012-RTM-Italian-64Bit-Base",
    "/aws/service/ami-windows-latest/Windows_Server-2016-English-Deep-Learning",
    "/aws/service/ami-windows-latest/Windows_Server-2016-English-Full-SQL_2014_SP3_Enterprise",
    "/aws/service/ami-windows-latest/Windows_Server-2019-English-Core-EKS_Optimized-1.21",
    "/aws/service/ami-windows-latest/Windows_Server-2019-Italian-Full-Base",
    "/aws/service/ami-windows-latest/Windows_Server-2019-Japanese-Full-SQL_2017_Enterprise",
    "/aws/service/ami-windows-latest/Windows_Server-2022-Italian-Full-Base",
    "/aws/service/ami-windows-latest/Windows_Server-2022-Portuguese_Brazil-Full-Base",
    "/aws/service/ami-windows-latest/Windows_Server-20H2-English-Core-ContainersLatest",
    "/aws/service/ami-windows-latest/EC2LaunchV2_Preview-Windows_Server-2019-English-Core-Base",
]

您可以使用以下命令檢視這些 AMIs 的詳細資訊,包括 AMI ID 和 Amazon Resource Name (ARN)。

Linux & macOS
aws ssm get-parameters-by-path \ --path "/aws/service/ami-windows-latest" \ --region region
Windows
aws ssm get-parameters-by-path ^ --path "/aws/service/ami-windows-latest" ^ --region region

region 代表 AWS Systems Manager 支援之 AWS 區域 的識別符,例如 us-east-2 代表美國東部 (俄亥俄) 區域。如需 region 值的清單,請參閱《Amazon Web Services 一般參考》中 Systems Manager 服務端點中的 Region (區域) 資料欄。

該命令會傳回相關資訊,如以下所示。此範例輸出因空間不足已被截斷。

{
    "Parameters": [
        {
            "Name": "/aws/service/ami-windows-latest/Windows_Server-2012-R2_RTM-Chinese_Simplified-64Bit-Base",
            "Type": "String",
            "Value": "ami-085a8792434781696",
            "Version": 72,
            "LastModifiedDate": "2021-11-11T16:29:44.401000-08:00",
            "ARN": "arn:aws:ssm:us-east-2::parameter/aws/service/ami-windows-latest/Windows_Server-2012-R2_RTM-Chinese_Simplified-64Bit-Base",
            "DataType": "text"
        },
        {
            "Name": "/aws/service/ami-windows-latest/Windows_Server-2012-R2_RTM-Chinese_Traditional-64Bit-Base",
            "Type": "String",
            "Value": "ami-01d65ee0d6d795b37",
            "Version": 72,
            "LastModifiedDate": "2021-11-11T16:30:04.345000-08:00",
            "ARN": "arn:aws:ssm:us-east-2::parameter/aws/service/ami-windows-latest/Windows_Server-2012-R2_RTM-Chinese_Traditional-64Bit-Base",
            "DataType": "text"
        },
        {
            "Name": "/aws/service/ami-windows-latest/Windows_Server-2012-R2_RTM-Dutch-64Bit-Base",
            "Type": "String",
            "Value": "ami-0ddf2b503c5585e35",
            "Version": 72,
            "LastModifiedDate": "2021-11-11T16:30:16.207000-08:00",
            "ARN": "arn:aws:ssm:us-east-2::parameter/aws/service/ami-windows-latest/Windows_Server-2012-R2_RTM-Dutch-64Bit-Base",
            "DataType": "text"
        }
    ]
}

您可以使用 GetParameters API 操作及完整 AMI 名稱 (包括路徑) 檢視特定 AMI 的詳細資訊。以下為範例命令。

Linux & macOS
aws ssm get-parameters \ --names /aws/service/ami-windows-latest/Windows_Server-2016-English-Core-Containers \ --region us-east-2
Windows
aws ssm get-parameters ^ --names /aws/service/ami-windows-latest/Windows_Server-2016-English-Core-Containers ^ --region us-east-2

此命令會傳回以下資訊。

{
    "Parameters": [
        {
            "Name": "/aws/service/ami-windows-latest/Windows_Server-2016-English-Core-Containers",
            "Type": "String",
            "Value": "ami-0581eb234ac9bf3ec",
            "Version": 68,
            "LastModifiedDate": "2021-11-11T16:40:51.934000-08:00",
            "ARN": "arn:aws:ssm:us-east-2::parameter/aws/service/ami-windows-latest/Windows_Server-2016-English-Core-Containers",
            "DataType": "text"
        }
    ],
    "InvalidParameters": []
}