Python 在boto3中找不到使用descripe_images()的linux映像

Python 在boto3中找不到使用descripe_images()的linux映像,python,boto3,Python,Boto3,使用boto3,当我在descripe_images()中以“platform”作为名称筛选图像时,我只会在使用“windows”作为其值时找到筛选结果,而当我尝试使用linux或ubuntu时,它似乎不起作用,我如何获得linux图像 def describe_images(images, platform = ['windows'] image_type = ['machine'], architecture = ['x86_64'], owners = ['amazon'], root_d

使用boto3,当我在descripe_images()中以“platform”作为名称筛选图像时,我只会在使用“windows”作为其值时找到筛选结果,而当我尝试使用linux或ubuntu时,它似乎不起作用,我如何获得linux图像

def describe_images(images, platform = ['windows'] image_type = ['machine'], architecture = ['x86_64'], owners = ['amazon'], root_device_type = ['instance-store']):#Not working when platform = ['linux']
global ec2

def describe(ec2):
    try:
        describe_img = ec2.describe_images(Filters = [{'Name' : 'platform', 'Values' : platform},{'Name' : 'image-type', 'Values' : image_type},{'Name' : 'architecture', 'Values' : architecture}, {'Name' : 'root-device-type', 'Values' : root_device_type}], Owners = owners, DryRun = False)
    except:
        raise
    else:
        for img in describe_img['Images']:
            #print('---img:',img)
            images.append(img['ImageId'])
            #print('---img[]:',img['ImageId'])
        print('len images:',len(images))
        print('---images:',images)
    
try:
    #print('describe images entered')
    describe_img = ec2.describe_images(DryRun = True)

except ClientError as e:
    #print('--if dry run op in e:','DryRunOperation' in str(e))
    if 'DryRunOperation' not in str(e):
        tkinter.messagebox.showerror(title = 'Error', message = 'It is found that the account doesn\'t have the permission(s) required to see the images. Please try again after obtaining the required permission(s).')
    elif 'DryRunOperation' in str(e):
        describe(ec2)
    else:
        raise
#print('leaving describe images.')

平台
选项仅适用于windows(从):

对于windows AMIs,此值设置为windows;否则,它是空白的

因此,要获取linux映像,请不要使用
平台
过滤器


但是,目前我不确定是否不使用该过滤器也将包括窗口或不。如果是,则您以后必须将其过滤掉,或者使用其他选项仅过滤特定于linux映像。

平台
选项仅适用于windows(从):

对于windows AMIs,此值设置为windows;否则,它是空白的

因此,要获取linux映像,请不要使用
平台
过滤器


但是,目前我不确定是否不使用该过滤器也将包括窗口或不。如果是,那么您以后必须将其过滤掉,或者使用其他选项只过滤特定于linux映像的映像。

通过其他选项,您是指一般使用python还是boto3提供的解决方案可以获得linux映像,如windows映像?@LaNa您是否在没有
平台
过滤器的情况下运行?可能它已经只提供了linux映像。我发现,虽然windows映像有“Platform”和“PlatformDetails”键,但linux映像只有“PlatformDetails”键,值为linux/UNIX。这可能是“平台”筛选器的值仅为“windows”的原因。@LaNa这是可能的。无论如何,如果我的回答有帮助的话,我们将非常感谢您的接受。另外一种选择是,您是指一般使用python还是boto3提供了一种解决方案来获取linux映像,如windows映像?@LaNa您是否在没有
平台
过滤器的情况下运行?可能它已经只提供了linux映像。我发现,虽然windows映像有“Platform”和“PlatformDetails”键,但linux映像只有“PlatformDetails”键,值为linux/UNIX。这可能是“平台”筛选器的值仅为“windows”的原因。@LaNa这是可能的。无论如何,如果我的回答有帮助的话,我们将不胜感激。