Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. # set SSE on all existing objects
  4.  
  5. #usage: encrypt_all_objects.py bucketname
  6.  
  7. import sys
  8. import boto
  9.  
  10. from boto import connect_s3
  11. from boto.s3 import connect_to_region
  12. from boto.s3.connection import S3Connection, OrdinaryCallingFormat
  13.  
  14. bucketname = sys.argv[1]
  15.  
  16. s3 = connect_to_region(
  17. 'ap-southeast-2',
  18. is_secure=True,
  19. calling_format = OrdinaryCallingFormat()
  20. )
  21.  
  22. bucket = s3.get_bucket(bucketname)
  23.  
  24. keys = bucket.list()
  25.  
  26. for k in keys:
  27. print(k.key)
  28. k.copy(bucketname, k.key, encrypt_key=True, preserve_acl=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement