通过AWS SNS服务从一个端点到另一个端点的HTTP标头 [英] http headers from one endpoint to other via AWS SNS service

查看:66
本文介绍了通过AWS SNS服务从一个端点到另一个端点的HTTP标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需求,我需要通过将其发布到SNS来从api A发送一些入站http查询参数,而其他api B则订阅了sns,它应该在其中获取查询参数.

I have a requirement where I need to send some inbound http query parameters from api A by publishing it to SNS and other api B is subscribed to sns where it should get the query params.

有什么办法可以实现?

注意:发布到SNS时,我有一个固定的消息结构,该结构无法更改,因为我已经订阅了SNS的其他端点依赖于它.

Note: I have a fixed message structure when I publish to SNS which I cannot change, since I have other endpoints who are already subscribing to SNS, depend on it.

正如Michael提到的,我们可以使用lambda.但我不想使用aws提供的其他服务.我只想使用SNS就能达到相同的效果.我听说过SNS消息属性,但不确定是否可以使用它来达到相同的目的.

As Michael mentioned, we can use lambda. but I do not want to use another service provided by aws. I want to acheive the same using SNS only. I heard about SNS message attributes, but not sure whether we can acheive the same using it.

谢谢.

推荐答案

SNS不支持自定义HTTP事务或以其他方式修改正在传递的消息...但是SNS确实支持针对Lambda函数的订阅.

SNS doesn't support customizing the HTTP transaction or otherwise modifying the message being delivered... but SNS does support subscriptions that target a Lambda function.

这意味着您可以编写一个Lambda函数来解析SNS事件有效负载...,然后,您的Lambda函数可以根据需要自定义向目标端点发出HTTPS请求,而不是SNS通过HTTPS与目标系统联系.如果HTTPS请求失败,或者端点返回错误,则Lambda函数应引发异常,以便Lambda可以重试.

This means you can write a Lambda function that parses the SNS event payload... and then, instead of SNS contacting the target system over HTTPS, your Lambda function makes the HTTPS request to the target endpoint, customized as required. If the HTTPS request fails, or the endpoint returns an error, the Lambda function should throw an exception, so that Lambda can know to retry.

https://docs.aws.amazon.com/lambda/latest/dg/invoking-lambda-function.html#supported-event-source-sns

这篇关于通过AWS SNS服务从一个端点到另一个端点的HTTP标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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