import boto.cloudfront import os import time if __name__ == '__main__': key = os.environ['AWS_ACCESS_KEY_ID'] secret = os.environ['AWS_SECRET_ACCESS_KEY'] distid = os.environ['BAYSEC_DISTID'] c = boto.cloudfront.CloudFrontConnection(key, secret) #help(c) #print(list(c.get_invalidation_requests(distid))) iq = c.create_invalidation_request(distid, [ '/*' ]) iqid = iq.id print('invalidation id:', iqid) for i in range(20): if iq.status == 'Completed': print('Done') break print('checking...') time.sleep(5) iq = c.invalidation_request_status(distid, iqid) else: print('failed, c is connection, iq is last request, iqid is Id of request') import pdb pdb.set_trace()