AWS CLI SNS 使用多个电子邮件地址订阅

问题描述 投票:0回答:3

如何通过 CLI 订阅具有多个电子邮件地址的 SNS 主题?

单一订阅进展顺利,如下所示

aws sns subscribe --topic-arn arn:aws:sns:ap-southeast-2:nnnnnn:abcd --protocol email --notification-endpoint  [email protected]

当我尝试使用(或空格)提交多封电子邮件时,它不起作用。可以吗?

amazon-web-services aws-cli amazon-sns
3个回答
1
投票

同样的你,我用两行 CLI 和两封电子邮件解决了 示例:

  • 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]


1
投票

不,这是不可能的。请参阅这两篇文章:

  1. Amazon 将多个订阅端点作为功能请求。有人指出 Google GCM API 确实已经具有此功能。
  2. 亚马逊文档指出当前订阅多个电话号码或电子邮件的方式是创建多个订阅。

0
投票

有一个关于为此提供自定义资源的 AWS 文档,但我发现他们的自定义资源不起作用...我能够通过使用类似于以下内容的 python 脚本来规避该问题:

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)

    

对我来说效果很好(MyEmails.txt 每行都有一个地址)。很确定 python 子进程的默认行为是等待进程完成,这样我就不用担心 aws 过载。我想我会发帖以防任何脚本小子正在努力帮助自己,并对一次手动订阅每个地址的前景感到遗憾。

© www.soinside.com 2019 - 2024. All rights reserved.