Search code examples
amazon-web-servicesamazon-ec2botoec2-ami

boto EC2 find all Ubuntu images?


How do I find all Ubuntu images available in my region?

Attempt:

from boto.ec2 import connect_to_region


conn = connect_to_region(**dict(region_name=region, **aws_keys))
if not filters:  # Not as default arguments, as they should be immutable
    filters = {
        'architecture': 'x86_64',
        'name': 'ubuntu/images/ebs-*'
    }
print conn.get_all_images(owners=['amazon'], filters=filters)

I've also tried setting ubuntu/images/ebs-ssd/ubuntu-trusty-14.04-amd64-server-20140927, ubuntu*, *ubuntu and *ubuntu*.


Solution

  • The AWS API does not accept globs in search filters as far as I am aware. You can use the owner id to find it. 'Amazon' is not the owner of the ubuntu images Canonical is.

    Change owners=['amazon'] to owners=['099720109477'].

    There is no owner alias for canonical as far as I can see, so you will have to use the owner id instead.

    Hope this helps.