Browse Source

add script to invalidate cache.

This maybe should be a default part of publish, but
I haven't decided if it is a good idea..  It could be
configuratable.
main
John-Mark Gurney 4 months ago
parent
commit
7a1509d3b1
1 changed files with 32 additions and 0 deletions
  1. +32
    -0
      invalidate.py

+ 32
- 0
invalidate.py View File

@@ -0,0 +1,32 @@
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()

Loading…
Cancel
Save