mirror of
https://github.com/FoggedLens/deflock.git
synced 2026-08-16 07:30:23 +02:00
add alarms for failed lambdas
This commit is contained in:
@@ -89,3 +89,23 @@ resource "aws_cloudwatch_log_group" "lambda_log_group" {
|
||||
name = "/aws/lambda/${aws_lambda_function.overpass_lambda.function_name}"
|
||||
retention_in_days = 14
|
||||
}
|
||||
|
||||
resource "aws_sns_topic" "lambda_alarms" {
|
||||
name = "${var.module_name}_lambda_alarms"
|
||||
}
|
||||
|
||||
resource "aws_cloudwatch_metric_alarm" "lambda_error_alarm" {
|
||||
alarm_name = "${var.module_name}_execution_error"
|
||||
alarm_description = "An error has occurred while executing the ${var.module_name} Lambda"
|
||||
namespace = "AWS/Lambda"
|
||||
metric_name = "Errors"
|
||||
dimensions = {
|
||||
FunctionName = aws_lambda_function.overpass_lambda.function_name
|
||||
}
|
||||
statistic = "Sum"
|
||||
period = 86400 # 1 day
|
||||
evaluation_periods = 1
|
||||
threshold = 0
|
||||
comparison_operator = "GreaterThanThreshold"
|
||||
alarm_actions = [var.sns_topic_arn]
|
||||
}
|
||||
|
||||
@@ -9,3 +9,8 @@ variable "deflock_cdn_bucket" {
|
||||
variable "rate" {
|
||||
description = "Rate at which to run the Lambda function"
|
||||
}
|
||||
|
||||
variable "sns_topic_arn" {
|
||||
description = "The ARN of the SNS topic for Lambda alarms"
|
||||
type = string
|
||||
}
|
||||
|
||||
@@ -120,3 +120,22 @@ resource "aws_iam_role_policy_attachment" "lambda_cloudwatch_logs_attachment" {
|
||||
role = aws_iam_role.lambda_role.name
|
||||
policy_arn = aws_iam_policy.lambda_cloudwatch_logs_policy.arn
|
||||
}
|
||||
|
||||
# Alarms for Failure
|
||||
|
||||
resource "aws_cloudwatch_metric_alarm" "lambda_error_alarm" {
|
||||
alarm_name = "${var.module_name}_execution_error"
|
||||
alarm_description = "An error has occurred while executing the ${var.module_name} Lambda"
|
||||
comparison_operator = "GreaterThanThreshold"
|
||||
evaluation_periods = 1
|
||||
metric_name = "Errors"
|
||||
namespace = "AWS/Lambda"
|
||||
period = 86400 # 1 day
|
||||
statistic = "Sum"
|
||||
threshold = 0
|
||||
dimensions = {
|
||||
FunctionName = aws_lambda_function.overpass_lambda.function_name
|
||||
}
|
||||
|
||||
alarm_actions = [var.sns_topic_arn]
|
||||
}
|
||||
|
||||
@@ -26,3 +26,8 @@ variable "aws_account_id" {
|
||||
type = string
|
||||
default = "912821578123"
|
||||
}
|
||||
|
||||
variable "sns_topic_arn" {
|
||||
description = "The ARN of the SNS topic for Lambda alarms"
|
||||
type = string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user