Skip to content

Commit 93e5413

Browse files
committed
⚡ sns topic
1 parent 768bc41 commit 93e5413

File tree

1 file changed

+34
-25
lines changed

1 file changed

+34
-25
lines changed

main.tf

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -106,36 +106,45 @@ resource "aws_cloudwatch_log_group" "lambda_logs" {
106106
##########################
107107
# Cloudwatch Alarm #
108108
##########################
109-
# resource "aws_cloudwatch_metric_alarm" "lambda_alarm" {
110-
# alarm_name = "${var.function_name}-lambda-execution-time"
111-
# comparison_operator = "GreaterThanOrEqualToThreshold"
112-
# evaluation_periods = "1"
113-
# metric_name = "Duration"
114-
# namespace = "AWS/Lambda"
115-
# period = "60"
116-
# statistic = "Maximum"
117-
# threshold = aws_lambda_function.lambda.timeout * 1000 * 0.75
118-
# alarm_description = "Lambda Execution Time"
119-
# treat_missing_data = "ignore"
109+
resource "aws_cloudwatch_metric_alarm" "lambda_alarm" {
110+
alarm_name = "${var.function_name}-lambda-execution-time"
111+
comparison_operator = "GreaterThanOrEqualToThreshold"
112+
evaluation_periods = "1"
113+
metric_name = "Duration"
114+
namespace = "AWS/Lambda"
115+
period = "60"
116+
statistic = "Maximum"
117+
threshold = aws_lambda_function.lambda.timeout * 1000 * 0.75
118+
alarm_description = "Lambda Execution Time"
119+
treat_missing_data = "ignore"
120120

121-
# insufficient_data_actions = [
122-
# "${aws_sns_topic.alarms.arn}",
123-
# ]
121+
insufficient_data_actions = [
122+
"${aws_sns_topic.alarms.arn}",
123+
]
124124

125-
# alarm_actions = [
126-
# "${aws_sns_topic.alarms.arn}",
127-
# ]
125+
alarm_actions = [
126+
"${aws_sns_topic.alarms.arn}",
127+
]
128128

129-
# ok_actions = [
130-
# "${aws_sns_topic.alarms.arn}",
131-
# ]
129+
ok_actions = [
130+
"${aws_sns_topic.alarms.arn}",
131+
]
132132

133-
# dimensions {
134-
# FunctionName = aws_lambda_function.lambda.function_name
135-
# Resource = aws_lambda_function.lambda.function_name
136-
# }
137-
# }
133+
dimensions {
134+
FunctionName = aws_lambda_function.lambda.function_name
135+
Resource = aws_lambda_function.lambda.function_name
136+
}
137+
}
138138

139139
##########################
140140
# SNS Topic #
141141
##########################
142+
resource "aws_sns_topic" "alarms" {
143+
name = "test-topic"
144+
}
145+
146+
resource "aws_sns_topic_subscription" "subscription" {
147+
topic_arn = data.aws_sns_topic.alarms.arn
148+
protocol = "email"
149+
endpoint = "[email protected]"
150+
}

0 commit comments

Comments
 (0)