【发布时间】:2018-04-08 03:47:45
【问题描述】:
我的 Lambda 函数应该在完成后向 SNS 发送消息,我正在使用下面的代码来执行此操作。我的 SNS 主题中的 TopicARN 绝对是正确的,但我仍然收到以下错误:
"errorMessage": "Parameter validation failed:\nUnknown parameter in input: \"TopicARN\", must be one of: TopicArn, TargetArn, PhoneNumber, Message, Subject, MessageStructure, MessageAttributes",
"errorType": "ParamValidationError",
有人可以检查我的代码,如果我在这里的格式做错了什么,请告诉我?我还可以告诉您,我认为已为该函数设置了适当的 IAM 角色,以便能够:
IAM 权限:
{
"Effect": "Allow",
"Action": "sns:publish",
"Resource": "*"
}
代码片段:
def notify_when_bad(error_code, error_text):
sns = boto3.client(service_name="sns")
topicArn = 'arn:aws:sns:us-east-1:xxxxxxxxxxxx:TopicName'
if response.status_code == 200:
sns.publish(
TopicARN = (topicArn),
Message = (str("Instance ") + str(centreon_instance_name) + str("has been successfully removed from Centreon")))
else:
sns.publish(
TopicArn = (topicArn),
Message = (str("Function failed with msg:") + str(error_text) + '\n' + str("Status Code:") + str(error_code)))
return
print(notify_when_bad(error_code, error_text))
【问题讨论】:
标签: python-3.x aws-lambda amazon-sns