-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathmain.tf
83 lines (68 loc) · 2.52 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
locals {
#Inflight message limits are determined by queue type. Options are standard or FIFO
inflight_messages_limit = var.queue_type == "standard" ? 120000 : 20000
}
resource "aws_cloudwatch_metric_alarm" "inflight_messages" {
count = var.enabled ? 1 : 0
alarm_name = "SQSInflightMessages_${var.queue_name}"
alarm_description = "SQS Inflight Messages has exceeded ${var.inflight_threshold}%"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = var.evaluation_periods
threshold = local.inflight_messages_limit * (var.inflight_threshold * 0.01)
alarm_actions = var.alarm_actions
ok_actions = var.ok_actions
insufficient_data_actions = []
metric_name = "ApproximateNumberOfMessagesNotVisible"
namespace = "AWS/SQS"
period = var.period
statistic = "Maximum"
dimensions = {
QueueName = var.queue_name
}
lifecycle {
create_before_destroy = true
}
}
resource "aws_cloudwatch_metric_alarm" "age_of_oldest_message" {
count = var.enabled ? 1 : 0
alarm_name = "SQSAgeOfOldestMessage_${var.queue_name}"
alarm_description = "SQS Age of Messages in the queue"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = var.evaluation_periods
threshold = var.age_of_oldest_message_threshold
alarm_actions = var.alarm_actions
ok_actions = var.ok_actions
insufficient_data_actions = []
metric_name = "ApproximateAgeOfOldestMessage"
namespace = "AWS/SQS"
period = var.period
statistic = "Maximum"
dimensions = {
QueueName = var.queue_name
}
lifecycle {
create_before_destroy = true
}
}
resource "aws_cloudwatch_metric_alarm" "message_size" {
count = var.enabled ? 1 : 0
alarm_name = "SQSMessageSize_${var.queue_name}"
alarm_description = "SQS Messages sizes have exceeded ${var.message_size_threshold}%"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = var.evaluation_periods
threshold = var.max_message_size * (var.message_size_threshold * 0.01)
alarm_actions = var.alarm_actions
ok_actions = var.ok_actions
insufficient_data_actions = []
treat_missing_data = "notBreaching"
metric_name = "SentMessageSize"
namespace = "AWS/SQS"
period = var.period
statistic = "Maximum"
dimensions = {
QueueName = var.queue_name
}
lifecycle {
create_before_destroy = true
}
}