Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import json
- import boto3
- def get_content_file(path):
- with open(path, 'rb') as content_file:
- data = content_file.read()
- return data
- def add_permission(topics):
- client = boto3.client('sns')
- results = []
- for topic in topics:
- response = client.add_permission(
- TopicArn=topic['TopicArn'],
- Label='Add_Pub_Perms',
- AWSAccountId=[
- '412729474065',
- ],
- ActionName=[
- "GetTopicAttributes",
- "SetTopicAttributes",
- "AddPermission",
- "RemovePermission",
- "DeleteTopic",
- "Subscribe",
- "ListSubscriptionsByTopic",
- "Publish",
- "Receive",
- ]
- )
- results.append(response)
- with open('permissions-results.txt', 'w') as results_file:
- results_file.write(json.dumps(results, indent=4))
- if __name__ == '__main__':
- content = get_content_file('results.txt')
- topics = json.loads(content)
- add_permission(topics)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement