def find_latest_ami(ec2):
    """
    Find the AMI ID of the latest HVM/EBS image published by Amazon.
    """

    # find latest official image with the given name
    response = ec2.describe_images(
        Filters=[
            dict(Name='name', Values=[
                'amzn-ami-hvm-*',
            ]),
            dict(Name='owner-id', Values=['137112412989']),
        ],
    )
    ebs_images = filter(lambda i: i['Name'].endswith('-ebs'),
                        response['Images'])
    latest_image = max(ebs_images, key=(lambda i: i['CreationDate']))
    assert latest_image

    ami_id = latest_image['ImageId']
    return ami_id