为什么从 AWS CLI 订阅 SNS 主题会生成意外负载?

Why does subscribing from AWS CLI to a SNS topic generate an unexpected payload?

我一定是做错了什么,但是当我尝试使用 AWS CLI 订阅 SNS 主题时,如下所示:

aws sns subscribe --topic-arn <valid-arn> --protocol http --endpoint-url <valid, accessible URL>

我得到一个完全出乎意料的 POST 负载:

POST /api/aws/sns HTTP/1.1
Host: <censored>
Accept-Encoding: identity
User-Agent: aws-cli/1.11.38 Python/3.6.0 Linux/4.8.13-1-ARCH botocore/1.5.1
X-Amz-Date: 20170120T140758Z
Authorization: <censored>
Content-Length: 127
Content-Type: application/x-www-form-urlencoded

Action=Subscribe&Version=2010-03-31&TopicArn=censored&Protocol=http[!http]

当根据the documentation:

Your code should read the HTTP headers of the HTTP POST requests that Amazon SNS sends to your endpoint. Your code should look for the header field x-amz-sns-message-type, which tells you the type of message that Amazon SNS has sent to you.

所以它应该是一个 JSON 文档,至少包含 x-amz-sns-message-type header.

此外,验证 POST 请求是从我的主机向 URL 端点发出的,这看起来很奇怪。

从 AWS CLI 订阅 SNS 主题与从 Web 控制台订阅 SNS 主题之间有根本区别吗?

您应该使用 --notification-endpoint 而不是 --endpoint-urlendpoint-url 参数用于告诉 AWSCLI 将实际 subscribe 请求发送到哪里。这就是您所看到的。

aws sns subscribe --topic-arn <valid-arn> --protocol http --notification-endpoint <valid, accessible URL>