Skip to content

Commit 1eda77a

Browse files
committed
Add monitoring for lambda errors
1 parent 8e0697b commit 1eda77a

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

terraform/envs/general/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ variable "ProjectId" {
77
type = string
88
default = "gsuite-dirsync"
99
}
10+
11+
variable "SnsArn" {
12+
type = string
13+
default = "arn:aws:sns:us-east-1:898906883758:DiscordGeneralAlerts"
14+
}

terraform/modules/dirsync/main.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,22 @@ resource "aws_cloudwatch_event_target" "lambda_target" {
9393
target_id = "DirsyncLambdaTarget"
9494
arn = aws_lambda_function.this.arn
9595
}
96+
97+
98+
resource "aws_cloudwatch_metric_alarm" "invocation_error" {
99+
alarm_name = "${local.sync_lambda_name}-error-invocation"
100+
alarm_description = "GSuite Directory Sync lambda threw a critical error."
101+
namespace = "AWS/Lambda"
102+
metric_name = "Errors"
103+
statistic = "Sum"
104+
period = "300"
105+
evaluation_periods = "1"
106+
comparison_operator = "GreaterThanThreshold"
107+
threshold = "1"
108+
alarm_actions = [
109+
var.SnsArn
110+
]
111+
dimensions = {
112+
FunctionName = local.sync_lambda_name
113+
}
114+
}

terraform/modules/dirsync/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ variable "SyncFrequency" {
1919
type = string
2020
description = "EventBridge cron frequency for triggering the sync lambda"
2121
}
22+
23+
variable "SnsArn" {
24+
type = string
25+
}

0 commit comments

Comments
 (0)