我的Lambda函数应该在SNS完成后向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))
答案 0 :(得分:2)
他们认为:
Unknown parameter in input: \"TopicARN\", must be one of: TopicArn,
当你做
时sns.publish( TopicARN = (topicArn),
因此,您将参数命名为TopicARN
,他们需要TopicArn
。
是的,参数区分大小写。