Skip to content

Instantly share code, notes, and snippets.

@rhenter
Created August 16, 2017 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhenter/8fda49ef0c2805242374d4d33f02eee4 to your computer and use it in GitHub Desktop.
Save rhenter/8fda49ef0c2805242374d4d33f02eee4 to your computer and use it in GitHub Desktop.
#!/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