Skip to content

Commit fd1421c

Browse files
authored
Fire priority alert if more than 6 alerts in 12 hours (#3)
* Fire priority alert if more than 6 alerts in 12 hours * Fix terraform
1 parent 898aa48 commit fd1421c

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

terraform/envs/general/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ module "dirsync" {
3838
LogRetentionDays = var.LogRetentionDays
3939
SyncFrequency = "rate(1 hour)"
4040
SnsArn = var.SnsArn
41+
PrioritySnsArn = var.PrioritySnsArn
4142
}

terraform/envs/general/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ variable "SnsArn" {
1212
type = string
1313
default = "arn:aws:sns:us-east-2:898906883758:DiscordGeneralAlerts"
1414
}
15+
16+
variable "PrioritySnsArn" {
17+
type = string
18+
default = "arn:aws:sns:us-east-2:898906883758:PriorityDiscordAlerts"
19+
}

terraform/modules/dirsync/main.tf

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ resource "aws_lambda_function" "this" {
6666
timeout = 900
6767
memory_size = 2048
6868
source_code_hash = data.archive_file.lambda_code.output_sha256
69-
# reserved_concurrent_executions = 1
69+
reserved_concurrent_executions = 1
7070
description = "GSuite Sync Lambda."
7171
environment {
7272
variables = {
@@ -132,3 +132,21 @@ resource "aws_cloudwatch_metric_alarm" "no_invocation" {
132132
FunctionName = local.sync_lambda_name
133133
}
134134
}
135+
136+
resource "aws_cloudwatch_metric_alarm" "repeated_errors" {
137+
alarm_name = "${local.sync_lambda_name}-repeated-errors"
138+
alarm_description = "GSuite Directory Sync lambda has had multiple errors in the past 12 hours."
139+
namespace = "AWS/Lambda"
140+
metric_name = "Errors"
141+
statistic = "Sum"
142+
period = "43200" # 12 hours
143+
evaluation_periods = "1"
144+
comparison_operator = "GreaterThanThreshold"
145+
threshold = "6"
146+
alarm_actions = [
147+
var.PrioritySnsArn
148+
]
149+
dimensions = {
150+
FunctionName = local.sync_lambda_name
151+
}
152+
}

terraform/modules/dirsync/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ variable "SyncFrequency" {
2323
variable "SnsArn" {
2424
type = string
2525
}
26+
27+
variable "PrioritySnsArn" {
28+
type = string
29+
}

0 commit comments

Comments
 (0)