我有一个SNS主题ARN,我正在尝试以编程方式指定为SES的EventDestination。我正在使用自定义CloudFormation资源,这是我的脚本的顺序:
在CloudFormation期间执行的Lambda有权列出该主题。但是当它创建EventDestination时。它无法找到主题。它会引发以下错误:
2018-02-05T23:42:22.538Z 357e9918-0ace-11e8-a033-b70f6bdba611 { InvalidSNSDestination: Could not access SNS topic <arn:aws:sns:us-east-1:846743712894:REDACTED>.
at Request.extractError (/var/task/src/sesRuleSet.js:17884:29)
at Request.callListeners (/var/task/src/sesRuleSet.js:20237:20)
at Request.emit (/var/task/src/sesRuleSet.js:20209:10)
at Request.emit (/var/task/src/sesRuleSet.js:30887:14)
at Request.transition (/var/task/src/sesRuleSet.js:30226:10)
at AcceptorStateMachine.runTo (/var/task/src/sesRuleSet.js:31033:12)
at /var/task/src/sesRuleSet.js:31045:10
at Request.<anonymous> (/var/task/src/sesRuleSet.js:30242:9)
at Request.<anonymous> (/var/task/src/sesRuleSet.js:30889:12)
at Request.callListeners (/var/task/src/sesRuleSet.js:20247:18)
message: 'Could not access SNS topic <arn:aws:sns:us-east-1:846743712894:REDACTED>.',
code: 'InvalidSNSDestination',
time: 2018-02-05T23:42:22.538Z,
requestId: '363abdd6-0ace-11e8-82ef-3ba09d6eb8e6',
statusCode: 400,
retryable: false,
retryDelay: 18.25373598353528 }
以下是相关代码:
.then(() => {
console.log('Checking Access to SNS topic');
return new Promise((resolve, reject) => {
const params: AWS.SNS.ListTopicsInput = {};
sns.listTopics(params, (err, data) => {
if (err) {
console.log(err);
return reject(err);
}
console.log(data);
return resolve();
});
});
})
.then(() => {
console.log('Create Configuration Set');
return new Promise((resolve, reject) => {
const params: AWS.SES.CreateConfigurationSetRequest = {
ConfigurationSet: {
Name: 'configset',
},
};
console.log(params);
ses.createConfigurationSet(params, (err, data) => {
if (err) {
return reject(err);
}
console.log(data);
resolve();
});
});
})
.then(() => {
console.log('Create Configuration Set Event Destination');
return new Promise((resolve, reject) => {
const params: AWS.SES.CreateConfigurationSetEventDestinationRequest = {
ConfigurationSetName: 'configset',
EventDestination: {
MatchingEventTypes: ['open', 'click'],
Name: 'OpenAndClickHandler',
SNSDestination: {
TopicARN: `REDACTED`,
},
},
};
console.log(params);
ses.createConfigurationSetEventDestination(params, (err, data) => {
if (err) {
return reject(err);
}
resolve();
});
});
答案 0 :(得分:1)
我认为我们需要知道的问题是帮助。你能发布到任何SNS主题吗?您的代码看起来很好,但您可能需要添加一个策略以允许SES发布到SNS主题
答案 1 :(得分:1)
您的代码看起来很好。您的SNS主题是否配置良好?
你的lambda在同一个地区吗?
您的lambda是否有权在SES ConfigurationSet中创建此事件?