我有一个SNS主题,我正在尝试以编程方式分配为SES的eventDestination。我正在使用自定义云形式资源,这是我脚本的顺序:
- 列出SNS中当前的主题(验证lambda运行可以访问SNS(
- 创建配置集
- 用主题创建事件目的地
在云形式期间执行的lambda可以访问列表主题。但是,当它开始创建事件时。它找不到这个话题。它引发以下错误:
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();
});
});
我认为我们需要知道的问题是。您可以发布任何SNS主题吗?您的代码看起来不错,但您可能需要添加策略以允许SES发布到SNS主题
您的代码看起来不错。您的SNS主题配置良好吗?
您的lambda在同一地区吗?
您的lambda是否可以访问SES Configurationset?