如何在本地测试AWS SNS? [英] How to test AWS SNS locally?

查看:161
本文介绍了如何在本地测试AWS SNS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要使用Amazon SNS service.我希望能够将 http rest订阅到SNS 主题以接收通知.

I want to use Amazon SNS service. And I want to have an ability to subscribe an http rest to SNS topic to receive notifications.

但是在本地,我的应用程序的URL为localhost,所以我不可能在本地测试应用程序的行为.

However locally my application has URL as localhost So it's impossible for me to test application behavior locally.

我找到了一篇有关使用ngrok服务器的文章,该文章使用一些公共IP而不是本地IP.

I found one article about using ngrok server, to use some public IP instead of local.

但是,对于我来说,这似乎不是一个很好的解决方案.

However it doesn't seem to be a good solution for me.

您对我如何在本地拥有一个工作的 SNS订户有任何想法吗?

Do you have any ideas how I could have a working SNS subscriber locally?

推荐答案

您还可以使用 ngrok 公开您的本地主机公开地.

You could also use ngrok to expose your localhost publicly.

它们的工作方式是动态创建一个子域,并将所有请求通过所需的端口传输到您的计算机.

They way it works is it creates a subdomain dynamically and tunnels all request to your machine on the desired port.

描述这种情况,我有一个运行在localhost:8080上的nginx. 我打开终端并运行ngrok 8080,它将进行终端会话并记录我的公共URL,例如"as78fh.ngrok.com".

Picture this scenario, I have a nginx running on localhost:8080. I open my terminal and run ngrok 8080, it will take my terminal session and log my public url, like 'as78fh.ngrok.com'.

如果我在另一台计算机上,请打开浏览器并导航到as78fh.ngrok.com/register,该请求从我的localhost:8080/通过隧道返回到Internet进行注册.

If I go on another computer, open the browser and navigate to as78fh.ngrok.com/register the request gets served from my localhost:8080/register through the tunnel back to the internet.

我将其用于许多棘手的开发,例如电子邮件webhooks,github集成,当然还有Amazon sns.

I use it for lots of tricky developments, like email webhooks, github integrations and, of course, amazon sns.

这篇关于如何在本地测试AWS SNS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆