SNSDestination导致意外的密钥错误

时间:2017-10-11 16:36:43

标签: javascript node.js amazon-web-services amazon-sns amazon-ses

为某些AWS SES事件创建配置集事件目标时,我遇到此错误。这是我传递给ses.createConfigurationSetEventDestination()的参数:

const destinationParams = {
  ConfigurationSetName: instance.id,
  EventDestination: {
    Name: instance.id,
    MatchingEventTypes: ['send', 'reject', 'bounce', 'complaint', 'delivery', 'open', 'click'],
    Enabled: true,
    SNSDestination: {
      TopicARN: topicArn,
    },
  },
};

我得到的错误是

UnexpectedParameter: Unexpected key 'SNSDestination' found in params.EventDestination

目前的控制流程如下:

  • ses.createConfigurationSet()
  • sns.createTopic() //创建要在以下位置使用的新TopicArn:
  • ses.createConfigurationSetEventDestination()

These are the docs I'm referencing

1 个答案:

答案 0 :(得分:2)

我正在改进我以前的答案:

我配置了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' } }

所以node.js sdk没有问题。