Knowledge Center Monthly Newsletter - March 2025
Stay up to date with the latest from the Knowledge Center. See all new and updated Knowledge Center articles published in the last month and re:Post’s top contributors.
我想将私有 HTTP 或 HTTPS 端点订阅到我的 Amazon Simple Notification Service (Amazon SNS) 主题。
要将私有 HTTP 或 HTTPS 端点订阅到 Amazon SNS 主题,请完成以下步骤。
from __future__ import print_function import json import urllib3 http = urllib3.PoolManager() def lambda_handler(event, context): url = "PRIVATE_HTTP/S_ENDPOINT_URL" sns_message_payload = event["Records"][0]["Sns"] sns_message_headers = { "x-amz-sns-message-id": sns_message_payload['MessageId'], "x-amz-sns-message-type": sns_message_payload["Type"], "x-amz-sns-subscription-arn" : event["Records"][0]["EventSubscriptionArn"], "x-amz-sns-topic-arn" : sns_message_payload["TopicArn"] } try: r = http.request('POST', url, headers=sns_message_headers, body=json.dumps(sns_message_payload)) print(r.data) except Exception as e: print(e)
有关详细信息,请参阅教程: 将 Lambda 与 Amazon SNS 结合使用。