amazon-web-services - 使用 serverless-offline-sns 通过来自托管 AWS SNS 的 SNS 消息调用 serverless-offline Lambda 函数
问题描述
serverless-offline-sns
在其文档中说,为了收听 AWS 上托管的 SNS,您需要以下内容:
custom:
serverless-offline-sns:
localPort: ${env:LOCAL_PORT}
remotePort: ${env:SNS_SUBSCRIBE_REMOTE_PORT}
host: 0.0.0.0
sns-subscribe-endpoint: ${env:SNS_SUBSCRIBE_ENDPOINT}
sns-endpoint: ${env:SNS_ENDPOINT}
但我不知道从哪里获得所需的环境值:
${env:SNS_SUBSCRIBE_REMOTE_PORT}
${env:SNS_SUBSCRIBE_ENDPOINT}
${env:SNS_ENDPOINT}
解决方案
阅读完源代码后,我能够在 AWS 中托管一个 SNS 来触发我的本地功能,因为文档不是很清楚
这是我使用的配置:
serverless-offline-sns:
sns-endpoint: sns.${self:provider.region}.amazonaws.com
sns-subscribe-endpoint: <ngrok_url>
remotePort: 80
localPort: <ngrok_port>
accountId: ${self:provider.accountId}
示例用法:
使用 ngrok:
ngrok http 4002
像这样设置配置:
serverless-offline-sns:
sns-endpoint: sns.${self:provider.region}.amazonaws.com
sns-subscribe-endpoint: xxxxxxxx.ngrok.io
remotePort: 80
localPort: 4002
accountId: ${self:provider.accountId}
推荐阅读
- python - 图像处理:OpenCV 的视差图像质量不佳
- ruby - 如何从for循环计算用户输入的数据
- java - 测试失败,我做错了什么?
- git - 如何授予机器对特定 GitHub 存储库的完全访问权限?
- go - 将二进制数据与go中的十六进制值匹配
- c# - 将带有 typeparam 的复杂类型作为 CascadeParameter 传递给子 RenderFragment
- c# - 将对象(字符串列表)转换为数据表
- kubeflow - 如何在 python 中的 Kubeflow 容器化组件之间传递数据或文件
- sql - 将 Inner Join Grouping SQL 转换为 Linq
- javascript - 分配“数组有选择值”后数组清除