调用AMI公有参数 - Amazon Web Services Systems Manager
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

调用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

调用AMIAmazon Linux 和 Amazon Linux 2 的公有参数

您可以查看所有 Amazon Linux 和 Amazon Linux 2 的列表AMIs在最新的Amazon Web Services 区域使用以下命令Amazon命令行界面 (AmazonCLI)。

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,包括AMIID 和 Amazon 资源名称 (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

区域表示Amazon Web Services 区域支持Amazon Web Services Systems Manager之外的压缩算法(例如us-east-2对于美国东部(俄亥俄)区域,请指定。有关受支持的列表区域值,请参阅区域在中的列Systems Manager 服务终端节点中的Amazon Web Services 一般参考

此命令会返回如下信息。此示例输出已由于空间问题截断。

{
    "Parameters": [
        {
            "Name": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-ebs",
            "Type": "String",
            "Value": "ami-0d75cc1d706735521",
            "Version": 7,
            "LastModifiedDate": 1543873943.358,
            "ARN": "arn:aws:ssm:us-east-2::parameter/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-ebs"
        },
        {
            "Name": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2",
            "Type": "String",
            "Value": "ami-0cd3dfa4e37921605",
            "Version": 7,
            "LastModifiedDate": 1543873943.47,
            "ARN": "arn:aws:ssm:us-east-2::parameter/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2"
        },
        {
            "Name": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-s3",
            "Type": "String",
            "Value": "ami-0a0e3ff8af8d19497",
            "Version": 7,
            "LastModifiedDate": 1543873943.576,
            "ARN": "arn:aws:ssm:us-east-2::parameter/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-s3"
        },
        {
            "Name": "/aws/service/ami-amazon-linux-latest/amzn-ami-minimal-hvm-x86_64-ebs",
            "Type": "String",
            "Value": "ami-0786a9626196d6dac",
            "Version": 7,
            "LastModifiedDate": 1543873943.682,
            "ARN": "arn:aws:ssm:us-east-2::parameter/aws/service/ami-amazon-linux-latest/amzn-ami-minimal-hvm-x86_64-ebs"
        },

您可以查看具体AMI通过使用GetParametersAPI 操作与完整的AMI名称,包括路径。以下是一个示例命令。

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

该命令将返回以下信息。

{
    "Parameters": [
        {
            "Name": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2",
            "Type": "String",
            "Value": "ami-061392db613a6357b",
            "Version": 16,
            "LastModifiedDate": 1552519670.776,
            "ARN": "arn:aws:ssm:us-west-2::parameter/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2"
        }
    ],
    "InvalidParameters": []
}

调用AMI的公有参数Windows Server

您可以查看所有Windows Server AMIs在最新的Amazon Web Services 区域使用以下命令AmazonCLI。

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/amzn2-ami-hvm-2.0.20190313-x86_64-gp2-SQL_2017_Express",
    "/aws/service/ami-windows-latest/amzn2-ami-hvm-2.0.20191217.0-x86_64-gp2-mono",
    "/aws/service/ami-windows-latest/EC2LaunchV2_Preview-Windows_Server-2019-English-Core-Base",
    "/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-2016-Korean-Full-SQL_2016_SP2_Standard",
    "/aws/service/ami-windows-latest/Windows_Server-2019-English-Core-EKS_Optimized-1.17",
]

您可以查看有关这些AMIs,包括AMIID 和 Amazon 资源名称 (ARN),使用以下命令。

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

区域表示Amazon Web Services 区域支持Amazon Web Services Systems Manager之外的压缩算法(例如us-east-2对于美国东部(俄亥俄)区域,请指定。有关受支持的列表区域值,请参阅区域在中的列Systems Manager 服务终端节点中的Amazon Web Services 一般参考

此命令会返回如下信息。此示例输出已由于空间问题截断。

{
            "Name": "/aws/service/ami-windows-latest/Windows_Server-2016-English-Core-Containers",
            "Type": "String",
            "Value": "ami-0b19f0a8c08620b34",
            "Version": 53,
            "LastModifiedDate": "2020-09-10T19:49:05.760000-07:00",
            "ARN": "arn:aws:ssm:us-east-1::parameter/aws/service/ami-windows-latest/Windows_Server-2016-English-Core-Containers",
            "DataType": "text"
        },
        {
            "Name": "/aws/service/ami-windows-latest/Windows_Server-2016-German-Full-Base",
            "Type": "String",
            "Value": "ami-068badb2c4fe9d831",
            "Version": 53,
            "LastModifiedDate": "2020-09-10T19:53:44.049000-07:00",
            "ARN": "arn:aws:ssm:us-east-1::parameter/aws/service/ami-windows-latest/Windows_Server-2016-German-Full-Base",
            "DataType": "text"
        },
        {
            "Name": "/aws/service/ami-windows-latest/Windows_Server-2016-Japanese-Full-SQL_2017_Web",
            "Type": "String",
            "Value": "ami-0b12e609d6733dac7",
            "Version": 20,
            "LastModifiedDate": "2020-09-10T19:55:24.166000-07:00",
            "ARN": "arn:aws:ssm:us-east-1::parameter/aws/service/ami-windows-latest/Windows_Server-2016-Japanese-Full-SQL_2017_Web",
            "DataType": "text"
        },

您可以查看具体AMI通过使用GetParametersAPI 操作与完整的AMI名称,包括路径。以下是一个示例命令。

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

该命令将返回以下信息。

{
    "Parameters": [
        {
            "Name": "/aws/service/ami-windows-latest/Windows_Server-2016-English-Core-Containers",
            "Type": "String",
            "Value": "ami-0315ac376f3dac169",
            "Version": 53,
            "LastModifiedDate": "2020-09-10T19:50:01.955000-07:00",
            "ARN": "arn:aws:ssm:us-west-2::parameter/aws/service/ami-windows-latest/Windows_Server-2016-English-Core-Containers",
            "DataType": "text"
        }
    ],
    "InvalidParameters": []
}