Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import json
  3.  
  4. import boto3
  5.  
  6.  
  7. def get_content_file(path):
  8. with open(path, 'rb') as content_file:
  9. data = content_file.read()
  10. return data
  11.  
  12.  
  13. def add_permission(topics):
  14. client = boto3.client('sns')
  15.  
  16. results = []
  17. for topic in topics:
  18. response = client.add_permission(
  19. TopicArn=topic['TopicArn'],
  20. Label='Add_Pub_Perms',
  21. AWSAccountId=[
  22. '412729474065',
  23. ],
  24. ActionName=[
  25. "GetTopicAttributes",
  26. "SetTopicAttributes",
  27. "AddPermission",
  28. "RemovePermission",
  29. "DeleteTopic",
  30. "Subscribe",
  31. "ListSubscriptionsByTopic",
  32. "Publish",
  33. "Receive",
  34. ]
  35. )
  36.  
  37. results.append(response)
  38.  
  39. with open('permissions-results.txt', 'w') as results_file:
  40. results_file.write(json.dumps(results, indent=4))
  41.  
  42.  
  43. if __name__ == '__main__':
  44. content = get_content_file('results.txt')
  45. topics = json.loads(content)
  46. add_permission(topics)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement