diff --git a/moto/ec2/models.py b/moto/ec2/models.py index e22ccb7d2..5995f71ab 100644 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -270,7 +270,7 @@ class TaggedEC2Resource(BaseModel): value = getattr(self, filter_name.lower().replace("-", "_"), None) if value is not None: - return [value] + return value raise FilterNotImplementedError(filter_name, method_name) diff --git a/tests/test_ec2/test_amis.py b/tests/test_ec2/test_amis.py index 525e23f45..2eefa3b12 100644 --- a/tests/test_ec2/test_amis.py +++ b/tests/test_ec2/test_amis.py @@ -1339,6 +1339,31 @@ def test_ami_attribute_user_and_group_permissions_boto3(): image.public.should.equal(False) +@mock_ec2 +def test_filter_description(): + # https://github.com/spulec/moto/issues/4460 + client = boto3.client("ec2", region_name="us-west-2") + + # Search for partial description + resp = client.describe_images( + Owners=["amazon"], + Filters=[{"Name": "description", "Values": ["Amazon Linux AMI*"]}], + )["Images"] + resp.should.have.length_of(4) + + # Search for full description + resp = client.describe_images( + Owners=["amazon"], + Filters=[ + { + "Name": "description", + "Values": ["Amazon Linux AMI 2018.03.0.20210721.0 x86_64 VPC HVM ebs"], + } + ], + )["Images"] + resp.should.have.length_of(1) + + # Has boto3 equivalent @mock_ec2_deprecated def test_ami_attribute_error_cases():