File tree Expand file tree Collapse file tree 11 files changed +57
-38
lines changed
account-wide-infrastructure
modules/lambda-errors-metric-alarm
infrastructure/modules/sns Expand file tree Collapse file tree 11 files changed +57
-38
lines changed Original file line number Diff line number Diff line change 1- module "lambda_errors_sns_topic" {
2- source = " ./modules/sns"
3- name = " nrlf_lambda_errors_topic"
4- prefix = local. prefix
5- }
6-
7- module "lambda_errors_cloudwatch_metric_alarm" {
8- source = " ./modules/cloudwatch"
9- name = " nrlf-lambda-errors"
10- prefix = local. prefix
1+ module "lambda_errors_cloudwatch_metric_alarm_dev" {
2+ source = " ./modules/lambda-errors-metric-alarm"
3+ name_prefix = " nhsd-nrlf--dev"
114
125 comparison_operator = " GreaterThanOrEqualToThreshold"
136 evaluation_periods = 1
Original file line number Diff line number Diff line change 11resource "aws_cloudwatch_metric_alarm" "metric_alarm" {
22 count = var. create_metric_alarm ? 1 : 0
33
4- alarm_name = " ${ var . prefix } --${ var . name } "
4+ alarm_name = " ${ var . name_prefix } --lambda-errors-metric_alarm "
55 alarm_description = var. alarm_description
66 actions_enabled = var. actions_enabled
77
8- alarm_actions = var . alarm_actions
8+ alarm_actions = [ aws_sns_topic . sns_topic . arn ]
99 ok_actions = var. ok_actions
1010 insufficient_data_actions = var. insufficient_data_actions
1111
File renamed without changes.
Original file line number Diff line number Diff line change 1+ data "aws_secretsmanager_secret" "emails" {
2+ name = " ${ var . name_prefix } -emails"
3+ }
4+
5+ data "aws_secretsmanager_secret_version" "emails" {
6+ secret_id = data. aws_secretsmanager_secret . emails . id
7+
8+ }
Original file line number Diff line number Diff line change 1+ resource "aws_sns_topic" "sns_topic" {
2+ name = " ${ var . name_prefix } --lambda-errors-sns-topic"
3+ }
4+
5+ resource "aws_sns_topic_subscription" "sns_subscription" {
6+ for_each = toset (data. aws_secretsmanager_secret_version . emails . secret_string )
7+ topic_arn = aws_sns_topic. sns_topic . arn
8+ protocol = " email"
9+ endpoint = each. value
10+ }
Original file line number Diff line number Diff line change @@ -128,6 +128,7 @@ variable "tags" {
128128 default = {}
129129}
130130
131- variable "prefix" {}
132-
133- variable "name" {}
131+ variable "name_prefix" {
132+ type = string
133+ description = " The prefix to apply to all resources in the module."
134+ }
Original file line number Diff line number Diff line change 1+ module "lambda_errors_cloudwatch_metric_alarm_dev" {
2+ source = " ./modules/lambda-errors-metric-alarm"
3+ name_prefix = " nhsd-nrlf--prod"
4+
5+ comparison_operator = " GreaterThanOrEqualToThreshold"
6+ evaluation_periods = 1
7+ metric_name = " Errors"
8+ namespace = " AWS/Lambda"
9+ period = 60
10+ statistic = " Maximum"
11+ threshold = 1
12+ unit = " Count"
13+ alarm_description = " This metric monitors the number of Lambda errors that have occurred"
14+ alarm_actions = [module . lambda_errors_sns_topic . sns_topic_arn ]
15+ }
Original file line number Diff line number Diff line change 1+ module "lambda_errors_cloudwatch_metric_alarm_dev" {
2+ source = " ./modules/lambda-errors-metric-alarm"
3+ name_prefix = " nhsd-nrlf--test"
4+
5+ comparison_operator = " GreaterThanOrEqualToThreshold"
6+ evaluation_periods = 1
7+ metric_name = " Errors"
8+ namespace = " AWS/Lambda"
9+ period = 60
10+ statistic = " Maximum"
11+ threshold = 1
12+ unit = " Count"
13+ alarm_description = " This metric monitors the number of Lambda errors that have occurred"
14+ alarm_actions = [module . lambda_errors_sns_topic . sns_topic_arn ]
15+ }
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments