SNS subscribe HTTPS endpoint

0

I'm attempting to integrate a Google Chat webhook with the SNS https protocol but am having difficulty.

command1:

aws sns subscribe --topic-arn arn:aws:sns:us-east-1:123456789012:MyTopic --protocol https --notification-endpoint 'https://chat.googleapis.com/v1/spaces/AAAAaikfLEo/messages?key=<your-key>&token=<your-token>'

output:

{ "SubscriptionArn": "pending confirmation" }

Here are the cloud monitoring logs.

{ "notification": { "messageId": "0b72f18b-4267-4766-9196-58sckdsjwswf", "topicArn": "arn:aws:sns:us-east-1:123456789012:MyTopic", "timestamp": "2023-03-11 05:57:32.278" }, "delivery": { "deliveryId": "0b72f18b-4267-4766-9196-58sckdsjwswf", "destination": "https://chat.googleapis.com/v1/spaces/AAAAaikfLEo/messages?key=<your-key>&token=<your-token>", "providerResponse": "Bad Request", "dwellTimeMs": 62, "statusCode": 400 }, "status": "SUCCESS" }

I tried other commands as well, but they were ineffective.

command2:

aws sns subscribe
--topic-arn arn:aws:sns:us-east-1:123456789012:MyTopic
--protocol https
--notification-endpoint 'https://chat.googleapis.com/v1/spaces/AAAAaikfLEo/messages?key=<your-key>&token=<your-token>'
--attributes '{"http":{"defaultContentEncoding":"UTF-8","headers":{"Content-Type":"application/json"}}}'

error:

Parameter validation failed: Invalid type for parameter Attributes.http, value: OrderedDict([('defaultContentEncoding', 'UTF-8'), ('headers', OrderedDict([('Content-Type', 'application/json')]))]), type: <class 'collections.OrderedDict'>, valid types: <class 'str'>

not greeting the error in command1 but receiving no response However, the status code in the logs is 400, so I'm not sure what the error is; it could be about the header or something else.

질문됨 일 년 전766회 조회
1개 답변
1

I think your first attempt was successful. However, you need to get the token that was sent to the URL and run the confirm-subscription. That might not be available to you.

You can also set this up following the instructions here: How do I use webhooks to publish Amazon SNS messages to Amazon Chime, Slack, or Microsoft Teams?.

profile pictureAWS
전문가
kentrad
답변함 일 년 전
  • Is it possible to do without lambda?

  • Yes, if you can get to the logs of the endpoint to submit the token. Otherwise you will need some proxy that subscribes to the topic. You can host that proxy on other things besides Lambda.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠