你可以使用 AWS CLI 滚动调试发布消息以便快速找到问题。同时,确保在发布消息时选择正确的主题,并检查在代码中是否启用了 SNS 中的所有选项。 以下是一个示例 Python 代码片段,用于发布消息到 SNS 主题:
import boto3
# Create an SNS client
sns = boto3.client('sns')
# Publish a message to the specified topic
response = sns.publish(
TopicArn='arn:aws:sns:us-west-2:123456789012:MyTopic',
Message='Hello world!',
)
# Print the message ID
print('Published message with ID: ' + response['MessageId'])
请确保在此代码中指定正确的主题 ARN,并替换消息文本以在 SNS 主题上发布适当的消息。