feat: add support for filtering by tags in describe_managed_prefix_lists (#4747)
This commit is contained in:
parent
99ea1d07c5
commit
72fdaa3552
@ -5610,6 +5610,7 @@ class ManagedPrefixListBackend(object):
|
||||
result = managed_prefix_lists
|
||||
if filters:
|
||||
result = filter_resources(managed_prefix_lists, filters, attr_pairs)
|
||||
result = describe_tag_filter(filters, managed_prefix_lists)
|
||||
|
||||
for item in result.copy():
|
||||
if not item.delete_counter:
|
||||
|
@ -76,6 +76,34 @@ def test_describe_managed_prefix_lists_with_prefix():
|
||||
lists_by_id[0]["OwnerId"].should.equal("aws")
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_describe_managed_prefix_lists_with_tags():
|
||||
ec2 = boto3.client("ec2", region_name="us-west-1")
|
||||
|
||||
untagged_prefix_list = ec2.create_managed_prefix_list(
|
||||
PrefixListName="examplelist", MaxEntries=2, AddressFamily="?"
|
||||
)
|
||||
untagged_pl_id = untagged_prefix_list["PrefixList"]["PrefixListId"]
|
||||
tagged_prefix_list = ec2.create_managed_prefix_list(
|
||||
PrefixListName="examplelist",
|
||||
MaxEntries=2,
|
||||
AddressFamily="?",
|
||||
TagSpecifications=[
|
||||
{
|
||||
"ResourceType": "prefix-list",
|
||||
"Tags": [{"Key": "key", "Value": "value"},],
|
||||
},
|
||||
],
|
||||
)
|
||||
tagged_pl_id = tagged_prefix_list["PrefixList"]["PrefixListId"]
|
||||
|
||||
tagged_lists = ec2.describe_managed_prefix_lists(
|
||||
Filters=[{"Name": "tag:key", "Values": ["value"]}]
|
||||
)["PrefixLists"]
|
||||
[pl["PrefixListId"] for pl in tagged_lists].should.contain(tagged_pl_id)
|
||||
[pl["PrefixListId"] for pl in tagged_lists].should_not.contain(untagged_pl_id)
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_get_managed_prefix_list_entries():
|
||||
ec2 = boto3.client("ec2", region_name="us-west-1")
|
||||
|
Loading…
Reference in New Issue
Block a user