我正在使用boto3通过过滤器获取所有可用的Amazon AMI(公共),我在Boto3文档中找到了client.describe_images(** kwargs)。但是我无法应用过滤器。这是2个示例代码,它们试图访问1. Windows上的所有AMI,以及其他2. OpenSUSE的代码。 Boto能够获取所有Windows AMI,但不能获取OpenSUSE。我想我不明白如何使用过滤器。在这种特殊情况下,谁能解释一下这些过滤器。
import boto3
client = boto3.client('ec2')
# Completed "aws configure" Access ID, Secret Key, Region in terminal
# I am Trying to get all the publicly available Windows AMI's
response = client.describe_images(
ExecutableUsers=[
'all',
],
Filters=[
{
'Name': 'platform',
'Values': [
'windows',
]
},
],
Owners=[
'679593333241', # all public ami's from amazon as owner
]
)
print(response)
# OUTPUT: I get a collection of available windows AMI
# A collection with all windows as its platfrom
# ----------------------Code 2-------------------------------------------
robot = boto3.client('ec2')
# Completed "aws configure" Access ID, Secret Key, Region in terminal
# I am Trying to get all the publicly available OpenSUSE AMI's
response2 = robot.describe_images(
ExecutableUsers=[
'all',
],
Filters=[
{
'Name': 'platform',
'Values': [
'OpenSUSE', # No response other than Windows
]
},
],
Owners=[
'679593333241',
],
)
print(response2)
# OUTPUT: I get empty collection
# A collection with all OpenSUSE as its platform is expected.