Javascript SNS目标导致意外的密钥错误
为某些AWS SES事件创建配置集事件目标时,我遇到了此错误。以下是我传递到ses.createConfigurationSetEventDestination()的参数: 我得到的错误是Javascript SNS目标导致意外的密钥错误,javascript,node.js,amazon-web-services,amazon-sns,amazon-ses,Javascript,Node.js,Amazon Web Services,Amazon Sns,Amazon Ses,为某些AWS SES事件创建配置集事件目标时,我遇到了此错误。以下是我传递到ses.createConfigurationSetEventDestination()的参数: 我得到的错误是 UnexpectedParameter: Unexpected key 'SNSDestination' found in params.EventDestination 到目前为止,控制流程如下所示: ses.createConfigurationSet() sns.createTopic()//创建要
UnexpectedParameter: Unexpected key 'SNSDestination' found in params.EventDestination
到目前为止,控制流程如下所示:
- ses.createConfigurationSet()
- sns.createTopic()//创建要在中使用的新TopicArn:
- ses.createConfigurationSetEventDestination()
我正在改进我以前的答案: 我配置了node.js sdk并试图重现该问题。我能够成功地创建
ConfigurationSet
并设置EventDestination
代码:
var AWS = require('aws-sdk');
AWS.config.update({region:'us-east-1'});
var ses = new AWS.SES();
/*const params1 = {
ConfigurationSet: {
Name: 'test'
}
};
ses.createConfigurationSet(params1, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
}); */
const destinationParams = {
ConfigurationSetName: 'test',
EventDestination: {
Name: 'testevent',
MatchingEventTypes: ['send', 'reject', 'bounce', 'complaint', 'delivery', 'open', 'click'],
Enabled: true,
SNSDestination: {
TopicARN: 'arn:aws:sns:us-east-1:XXXXXXXXXXX:test',
},
},
};
ses.createConfigurationSetEventDestination(destinationParams, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
{ ResponseMetadata: { RequestId: '838b95ae-af35-11e7-a190-c960102424be' } }
响应:
var AWS = require('aws-sdk');
AWS.config.update({region:'us-east-1'});
var ses = new AWS.SES();
/*const params1 = {
ConfigurationSet: {
Name: 'test'
}
};
ses.createConfigurationSet(params1, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
}); */
const destinationParams = {
ConfigurationSetName: 'test',
EventDestination: {
Name: 'testevent',
MatchingEventTypes: ['send', 'reject', 'bounce', 'complaint', 'delivery', 'open', 'click'],
Enabled: true,
SNSDestination: {
TopicARN: 'arn:aws:sns:us-east-1:XXXXXXXXXXX:test',
},
},
};
ses.createConfigurationSetEventDestination(destinationParams, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
{ ResponseMetadata: { RequestId: '838b95ae-af35-11e7-a190-c960102424be' } }
因此,node.js sdk没有问题。对象属性是字符串还是标识符应该没有区别。不管怎样,我确实试过了,但没用。尽管我觉得一开始没什么不同。但在pythonapi中,它起了作用。它将抛出
namererror:name'SNSDestination'未定义
如果我不将其作为字符串提及。我几乎是一字不差地复制了您的代码,但仍然会收到相同的错误。我可以很好地生成一个配置集,但是snsdestinition仍然给了我意外参数:在params中发现了意外的键'snsdestinition'。EventDestination
我发现问题是我必须升级aws,哈哈。谢谢你的帮助!哈哈哈。。美好的这是要检查的下一个逻辑步骤,因为您的代码没有问题。我使用下面添加的node.js sdk成功地执行了ses.createConfigurationSetEventDestination()
,没有任何问题。您能否添加整个代码以缩小问题范围,并添加收到的整个错误
响应。