Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Boto3 ec2描述_图像速度太慢_Python_Amazon Web Services_Amazon Ec2_Boto3 - Fatal编程技术网

Python Boto3 ec2描述_图像速度太慢

Python Boto3 ec2描述_图像速度太慢,python,amazon-web-services,amazon-ec2,boto3,Python,Amazon Web Services,Amazon Ec2,Boto3,我有以下代码片段来获取amazon机器图像: session.client('ec2', region_name=AWS_DEFAULT_REGION).describe_images(ExecutableUsers=[ 'all', ], Filters=[ { 'Name': 'platform', 'Values

我有以下代码片段来获取amazon机器图像:

session.client('ec2', region_name=AWS_DEFAULT_REGION).describe_images(ExecutableUsers=[
               'all',
           ],
           Filters=[
               {
                   'Name': 'platform',
                   'Values': [
                       'windows',
                   ]
               },
               {
                   'Name': 'state',
                   'Values': [
                       'available',
                   ]
               },
               {
                   'Name': 'image-type',
                   'Values': [
                       'machine',
                   ]
               },
               {
                   'Name': 'virtualization-type',
                   'Values': [
                       'hvm',
                   ]
               },
               {
                   'Name': 'root-device-type',
                   'Values': [
                       'ebs',
                   ]
               },
           ],
           Owners=[
               '679593333241', # all public ami's from amazon as owner
           ])
这是可行的,但是响应太慢了,我知道AMI列表很长,但我不需要列表上的所有AMI,我只需要最流行的AMI元素(red hat、amazon linux、centos等),如果我使用Owners=['self'],它返回空值,启动新实例时,如何在快速启动菜单中的aws控制台中创建AMI元素的排序列表(参见图)?这个列表有38个元素


与使用
descripe_images()
不同,您可能希望使用Amazon EC2 Systems Manager-Parameter Store的一个特殊功能,该功能可以提供最近由Amazon管理的AMI的AMI ID

例如:

aws ssm get-parameters --names /aws/service/ecs/optimized-ami/amazon-linux-2/recommended --region us-east-1
返回:

{
    "Parameters": [
        {
            "Name": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended",
            "Type": "String",
            "Value": "{\"schema_version\":1,\"image_name\":\"amzn2-ami-ecs-hvm-2.0.20181017-x86_64-ebs\",\"image_id\":\"ami-0a6be20ed8ce1f055\",\"os\":\"Amazon Linux 2\",\"ecs_runtime_version\":\"Docker version 18.06.1-ce\",\"ecs_agent_version\":\"1.21.0\"}",
            "Version": 1,
            "LastModifiedDate": 1539908415.817,
            "ARN": "arn:aws:ssm:us-east-1::parameter/aws/service/ecs/optimized-ami/amazon-linux-2/recommended"
        }
    ],
    "InvalidParameters": []
}
见: