Reputation: 529
How to subscribe to an SNS topic with multiple email addresses via CLI ?
Single subscription is going well as given below
aws sns subscribe --topic-arn arn:aws:sns:ap-southeast-2:nnnnnn:abcd --protocol email --notification-endpoint [email protected]
when I try to submit to multiple emails with (, or a space), it doesn't work. Is it possible?
Upvotes: 4
Views: 10888
Reputation: 1
There was an AWS Doc regarding providing a custom resource for this but I found their custom resource to not work... I was able to circumvent the issue by using a python script akin to the following:
import sys
import subprocess
f = open("MyEmails.txt", "r")
for line in f:
line = line.rstrip('\n')
result = subprocess.run(["aws sns subscribe --topic-arn MY_TOPIC_ARN --protocol email --notification-endpoint " + line], shell=True, capture_output=True, text=True)
print(result.stdout)
Worked perfectly for me (MyEmails.txt just had an address on each line). Pretty sure default behavior of python subprocesses is to wait until process is finished so I wouldn't worry about overloading aws. Figured I'd post in case any script kiddies were struggling to help themselves and were lamenting the prospect of manually subscribing each address one at a time.
Upvotes: 0
Reputation: 2426
No, it is not possible. See these two articles:
Upvotes: 2
Reputation: 21
The same you, I resolved with two lines Cli with two email example:
aws sns subscribe --topic-arn arn:aws:sns:ap-southeast-2:nnnnnn:abcd --protocol email --notification-endpoint [email protected]
aws sns subscribe --topic-arn arn:aws:sns:ap-southeast-2:nnnnnn:abcd --protocol email --notification-endpoint [email protected]
Upvotes: 2