通过 localstack 中的 SES 发送电子邮件,事件目的地带有 sns 主题,不起作用

2023-12-12

当在 localstack 中使用 SES 触发电子邮件时,我试图在队列中接收消息。 SES 服务正在使用连接到 SNS 主题的事件目标。 SNS主题连接到一个队列,我想在其中接收跳出、点击信息。

步骤如下:

// 1 whitelist email sender
aws --endpoint-url=http://localhost:4566 ses verify-email-identity --email-address [email protected] --profile test-profile --region eu-central-1 --output table | cat

// 2 create sqs queue
aws --endpoint-url=http://localhost:4566 sqs create-queue --queue-name ses_events_queue --profile test-profile --region eu-central-1 --output table | cat

// 3 create sns topic
aws --endpoint-url=http://localhost:4566 sns create-topic --name ses_events_topic --region eu-central-1 --profile test-profile --output table

// 4 subscribe sqs queue to sns topic
aws --endpoint-url=http://localhost:4566 sns subscribe --topic-arn arn:aws:sns:eu-central-1:000000000000:ses_events_topic --protocol sqs --notification-endpoint arn:aws:sqs:eu-central-1:000000000000:ses_events_queue --profile test-profile --region eu-central-1 --output table | cat

直到这里,如果我发布一条消息:

aws --endpoint-url=http://localhost:4566 sns publish --topic-arn arn:aws:sns:eu-central-1:000000000000:ses_events_topic --message "{\"subject\":\"Subject\",\"body8\":\"Body 8\",\"from\":\"[email protected]\",\"to\":\"[email protected]\"}" --profile test-profile --region eu-central-1 --output table | cat

它有效,我可以看到队列中的消息。

现在SES设置:

// 5 create config set
aws --endpoint-url=http://localhost:4566 ses create-configuration-set --configuration-set "{\"Name\":\"ses_config_set\"}" --profile test-profile --region eu-central-1 --output table | cat

// 6 create event destination
aws --endpoint-url=http://localhost:4566 ses create-configuration-set-event-destination --configuration-set-name ses_config_set --event-destination '{"Name":"some_name2","Enabled":true,"MatchingEventTypes":["send","bounce","delivery","open"],"SNSDestination":{"TopicARN":"arn:aws:sns:eu-central-1:000000000000:ses_events_topic"}}' --profile test-profile --region eu-central-1 --output table | cat

现在实际发送电子邮件:

// 7 send email via ses using config set
aws --endpoint-url=http://localhost:4566 ses send-email --destination '{"ToAddresses":["[email protected]"]}' --message '{"Subject":{"Data":"some sub","Charset":"string"},"Body":{"Text":{"Data":"some tesxt body","Charset":"string"}}}' --configuration-set-name ses_config_set --from '[email protected]' --profile test-profile --region eu-central-1 --output table | cat

电子邮件已发送,但如果我检查队列中的邮件,则没有:

aws --endpoint-url=http://localhost:4566 sqs receive-message --queue-url http://localhost:4566/000000000000/ses_events_queue --profile test-profile --region eu-central-1  --output table | cat

不确定错误出在哪里。我也不确定调试的最佳方法是什么。我尝试使用--debug在电子邮件发送中,但我找不到任何有用的东西。

我的怀疑是create event destination步骤可能是错误的,因为里面可能有选项,但不确定。

我还尝试向队列添加权限:

aws --endpoint-url=http://localhost:4566 sqs set-queue-attributes --queue-url http://localhost:4566/000000000000/ses_events_queue --attributes file://set_queue_attributes.json --profile test-profile --region eu-central-1 --output table | cat

in set_queue_attributes.json:

{"Policy" : "{\"Id\": \"Policy1564523767951\",\"Version\": \"2012-10-17\",\"Statement\": [{\"Sid\": \"Stmt1564523766749\",\"Action\": \"sqs:*\",\"Effect\": \"Allow\",\"Resource\": \"arn:aws:sqs:us-east-1:12345678:example-queue\",\"Condition\": {\"ArnEquals\": {\"aws:SourceArn\": \"arn:aws:sns:us-east-1:73628827939:MySNS\"}},\"Principal\": \"*\"}]}"}

但它也不起作用。不确定这是否是问题所在,因为直接发布到sns,我可以看到queue收到消息。我不知道如何调试,那ses发送消息,并且ses在中发布消息sns topic


在文档中,他们指出

无论您创建新的 SNS 主题还是选择现有主题,您都需要授予 SES 访问权限才能向该主题发布通知。

对于您的情况,请尝试在步骤 3 //create sns topic 之后添加此权限

awslocal sns add-permission \
--topic-arn arn:aws:sns:eu-central-1:000000000000:ses_events_topic \
--label Publish-Permission \
--aws-account-id 000000000000 \
--action-name Publish

我用的是薄包装纸awslocal

另外,在“sqs receive-message”中使用选项“--max-number-of-messages 10”。 默认值为“1”

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

通过 localstack 中的 SES 发送电子邮件,事件目的地带有 sns 主题,不起作用 的相关文章

随机推荐

  • jQuery 在第一个 11 后停止“单击”操作

    有两个嵌套元素 两者都有不同的click行动 单击内部元素时 我需要停止外部元素操作 HTML div div div div jQuery out click function alert OUT div is pressed in cl
  • 读取 Magic Mouse 和 Apple 无线键盘的电池百分比

    我想问您是否有人知道在 Mac 操作系统中访问鼠标和键盘电池状态的简单方法 有一些API可以访问这些信息吗 谢谢 对于键盘来说是 ioreg n IOAppleBluetoothHIDDriver grep i batterypercent
  • Ruby:仅在某些情况下重载运算符行为

    我的问题是 如何在内置类 例如 Integer new 上重载运算符 但仅限于某些情况 具体取决于第二个操作数的类 这是我正在寻找的行为 myObject myClass new 1 myObject gt special behaviou
  • 移动向量

    我有一个数据框 我想 对齐 每一列 以便每列的最大值位于同一行 我试图使用基本功能来做到这一点 但得到了错误的结果 即 只是覆盖而不转移 我刚刚在 Hmisc 中找到了 Lag 函数 但是 我确信有一种方法可以在基础上做到这一点 我只是想错
  • 函数式语言中的“模式匹配”是什么?

    我正在阅读有关函数式编程的内容 我注意到模式匹配许多文章都提到它是函数式语言的核心特性之一 有人可以为 Java C JavaScript 开发人员解释一下这是什么意思吗 理解模式匹配需要解释三个部分 代数数据类型 什么是模式匹配 为什么它
  • 如何在 javascript 中使用 i18next 中的翻译

    我知道我可以使用 i18next 来翻译 html 中的语言 例如 div div 但是有没有办法在 JS 中使用它 例如 如果我想做类似的事情 alert someKey 它应该是alert t someKey see http i18n
  • 打开 dfm 文件时出错 - 未找到类 xxxx

    通过双击打开 dfm 文件时 出现以下错误 Class TMyClass not found Ignore the error and continue Note Ignoring the error may cause component
  • 你要在c#中获取windows安装SID吗?

    我知道这个问题已经被问过很多次了 但没有人回答我的问题 我从 Comptiat A 的研究中了解到 当使用自动化 无人值守 安装时 技术人员总是必须返回并更改机器 SID 然后才能在每台计算机上激活操作系统 似乎有很多关于如何通过网络获取S
  • 如何匹配 powershell 中的 wsl 输出? [复制]

    这个问题在这里已经有答案了 我想查看我是否正在运行特定的 wsl 发行版 Windows 10 Home WSL 2 PS C Users User gt wsl list running Windows Subsystem for Lin
  • QTP 数据表操作*极其*慢(在 MMDRV 批处理执行器下好多了)?

    可能是一个精彩的故事 QTP 似乎无缘无故地浪费了你的工作时间 考虑这个脚本 其中的数据表只有一个全局行 有 26 列 名为 A 到 Z 填充了任意值 Print Started Services StartTransaction Simp
  • 连接一组点得到非自相交非凸多边形

    我有一组无序的二维点 代表建筑物的角点 我需要将它们连接起来以获得建筑物的轮廓 这些点是通过组合不同个体收集的不同多边形来获得的 我的想法是使用这些多边形来按顺序获取点 例如 获取最大和最小多边形之间的区域并连接这些点 使其位于该区域中 我
  • 使用iText创建具有完整外观的签名

    我需要创建签名 其中仅包含签名姓名和日期 另外 这两个字段必须放置在精确的坐标处 因为这两个字段必须放置在预定义的 修订表 中 这可能吗 这是我的代码 它与 Bruno Lowagie 的示例非常 非常相似 并且可能甚至不接近问题的解决方案
  • Android 地图:如何在地图上设置折线动画?

    当我在地图上从点 A gt B 绘制折线时 我需要用动画绘制折线 就像从 A gt B 一样 折线继续绘制 我使用下面的链接作为参考 https github com amalChandran google maps route anima
  • codeigniter 将 pdf 文件作为电子邮件附件发送

    我正在使用即时生成 pdf 文件TCPDF 通过使用 TCPDF 我得到了使用 Base64 编码的原始文件 现在我想使用以下命令将此原始数据作为电子邮件附件发送codeigniter电子邮件助手功能 怎么能做到这一点呢 我花了一段时间才找
  • 我想向 pandas 数据框添加新索引

    我正在尝试向 pandas 数据框添加新索引 数据框如下所示 date price neg vol pos vol 0 2017 10 17 01 00 00 51 88 11 4 1 2017 10 17 01 00 00 51 89 1
  • 使用 tablesorter 对多个表进行排序

    我正在使用 jQuery tablesorter 插件来允许用户对我们网站上的数据表进行排序 我最近遇到一个区域 其中使用表排序器的多个表将显示在同一页面上 我对此没有遇到任何问题 并且表排序器插件工作得很好 一些用户要求我们能够同时对所有
  • SQLite Android 应用程序登录

    我目前正在开发一款游戏 我想要的只是我的登录屏幕能够检查我已经存储在数据库中的用户名和密码是否正确 以及何时正确并且单击登录按钮打开一项新活动 我已经构建了数据库 并且还建立了登录名 我只需要弄清楚如何检查我的数据库而不仅仅是字段中的文本
  • MySQL-Win10升级后Wamp服务器无法工作

    我刚刚升级到 Windows 10 升级后我的 MySQl 未启动 wamp 服务器图标橙色 我可以看到 Apache 服务器正在运行 但 MySQL 未运行 请帮忙 Thanks 解决了 这对我有用 我去了 wamp bin mysql
  • 将字符串中读取的输入列表转换为Python中的列表

    我正在阅读一个包含列表的文件 下面是输入文件 1 2 3 4 42 1 1 2 3 5 8 现在 如您所见 有一些列表被读取为字符串字符 我正在尝试将其转换为实际列表 下面是我正在使用的代码 list list sys stdin read
  • 通过 localstack 中的 SES 发送电子邮件,事件目的地带有 sns 主题,不起作用

    当在 localstack 中使用 SES 触发电子邮件时 我试图在队列中接收消息 SES 服务正在使用连接到 SNS 主题的事件目标 SNS主题连接到一个队列 我想在其中接收跳出 点击信息 步骤如下 1 whitelist email s