Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import json
  4.  
  5. import boto3
  6.  
  7.  
  8. S3_BUCKET = '<insert bucket name>'
  9. SNS_ARN = '<insert sns arn>'
  10.  
  11. bucket = boto3.resource('s3').Bucket(S3_BUCKET)
  12. topic = boto3.resource('sns').Topic(SNS_ARN)
  13.  
  14.  
  15. for item in bucket.objects.all():
  16. if not item.key.endswith('.json.gz'):
  17. continue
  18.  
  19. message = json.dumps({
  20. 's3Bucket': S3_BUCKET,
  21. 's3ObjectKey': [item.key]
  22. })
  23.  
  24. topic.publish(Message=message)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement