Reputation: 101
I'm using boto 3 in python 3.5.2 trying to describe ec2 images. The doc says one of the available filters is 'is-public':
is-public - A Boolean that indicates whether the image is public.
But the Filter syntax wants a list of strings - and only a list of strings - for the Value. If I try passing a Boolean, it gives me a type error:
Invalid type for parameter Filters[0].Values[0], value: False, type: <class 'bool'>, valid types: <class 'str'>
My code:
response = session.client("ec2").describe_images(
Filters=[
{'Name': 'is-public',
'Values': [False],
},
How do I pass a Boolean filter when it will only accept a string?
Thanks... Bill
Upvotes: 3
Views: 1583
Reputation: 31
This works for me... use lower case.
ami_filter = [{"Name": "platform", 'Values': ["windows"]},
{"Name": "virtualization-type", 'Values': ["hvm"]},
{"Name": "image-type", 'Values': ["machine"]},
{"Name": "architecture", 'Values': ["x86_64"]},
{"Name": "state", 'Values': ["available"]},
{"Name": "is-public", 'Values': ['false']}]
ami_owners = ['amazon']
results = client.describe_images(Filters=ami_filter, Owners=ami_owners)
Upvotes: 3