过滤 DHCP 选项设置 Boto3

Filter DHCP Options Sets Boto3

我想使用 Boto3 按域名和域名服务器过滤 DHCP 选项集。文档说明我可以使用多个过滤器。 https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#dhcpoptions

看来我应该能够以某种方式使用“密钥”过滤器来过滤域名。

"key - 选项之一的键(例如, domain-name )。"

以下代码会产生错误。

def query_dhcp_options_set():

    ec2_client = boto3.client('ec2', region_name='us-west-1')

    filters = [
        {'Name':'domain-name', 'Values':['example.com']},
    ]

    return ec2_client.describe_dhcp_options(Filters=filters)

botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the DescribeDhcpOptions operation: The filter 'domain-name' is invalid

我也试过下面的代码

def query_dhcp_options_set():

    ec2_client = boto3.client('ec2', region_name='us-west-1')

    filters = [
        {'Name':'key:domain-name', 'Values':['example.com']},
    ]

    return ec2_client.describe_dhcp_options(Filters=filters)

botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the DescribeDhcpOptions operation: The filter 'key:domain-name' is invalid

能否提供一个查询域名和域名服务器设置的DHCP选项的例子属性?

尝试[ { "Name":"key", "Values":[ "domain-name" ] }, { "Name":"value", "Values":[ "example.com" ] } ]