Created
August 16, 2017 21:52
-
-
Save rhenter/8fda49ef0c2805242374d4d33f02eee4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment