diff --git a/moto/ec2/models.py b/moto/ec2/models.py index 08b4e3588..73b630146 100644 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -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: diff --git a/tests/test_ec2/test_prefix_lists.py b/tests/test_ec2/test_prefix_lists.py index e145f57cb..9c3cb495d 100644 --- a/tests/test_ec2/test_prefix_lists.py +++ b/tests/test_ec2/test_prefix_lists.py @@ -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")