![](/img/trans.png)
[英]What if my lambda job, which is subscribed to an AWS SNS topic, goes down or stops working?
[英]AWS lambda subscribed to SNS topic not working
I was creating a lambda function using node js and executing the simple function, in case of the function returns failure need to trigger an email.
exports.handler = async function(event) {
const promise = new Promise(function(resolve, reject) {
https.get(url, (res) => {
resolve(res.statusCode)
}).on('error', (e) => {
reject(Error(e))
})
})
return promise
}
AWSLambdaSNSTopicDestinationExecutionRole JSON 格式
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sns:Publish",
"Resource": "arn:aws:sns:xxx-xxxxxx-x:12435693:XXXXXXX"
}
]
}
AWSLambdaVPCAccessExecutionRole
{
"Version": "2008-10-17",
"Id": "__default_policy_ID",
"Statement": [
{
"Sid": "__default_statement_ID",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"SNS:Publish",
"SNS:RemovePermission",
"SNS:SetTopicAttributes",
"SNS:DeleteTopic",
"SNS:ListSubscriptionsByTopic",
"SNS:GetTopicAttributes",
"SNS:AddPermission",
"SNS:Subscribe"
],
"Resource": "arn:aws:sns:xxxx-2:xxxxxx1:xxxxxx",
"Condition": {
"StringEquals": {
"AWS:SourceOwner": "xxxxxxxx"
}
}
},
{
"Sid": "__console_sub_0",
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam::xxxxxx1:root",
"arn:aws:iam::xxxxxx2:root"
]
},
"Action": "SNS:Subscribe",
"Resource": "arn:aws:sns:xxxx-2:xxxxxx1:xxxxxx_TP"
}
]
}
當我綁定執行 lambda function 以防發生故障時,我沒有得到任何 email。 即使我也嘗試訂閱成功案例的主題,但我沒有收到任何 email。 任何人都可以面對這個問題嗎?
Lambda 的目的地僅用於您的函數的異步調用。 如果您從控制台或正常同步方式運行 function,則不會觸發目標。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.