File tree Expand file tree Collapse file tree 11 files changed +33
-19
lines changed
terraform/account-wide-infrastructure
lambda-errors-metric-alarm Expand file tree Collapse file tree 11 files changed +33
-19
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,8 @@ module "source" {
104104 # terraform_role_arn = data.aws_caller_identity.current.arn
105105 terraform_role_arn = " arn:aws:iam::${ var . assume_account } :role/${ var . assume_role } "
106106
107+ notification_target_email_addresses = local. notification_emails
108+
107109 backup_plan_config = {
108110 " compliance_resource_types" : [
109111 " S3"
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ module "lambda_errors_cloudwatch_metric_alarm_dev" {
22 source = " ../modules/lambda-errors-metric-alarm"
33 name_prefix = " nhsd-nrlf--dev"
44
5+ notification_emails = local. notification_emails
6+
57 evaluation_periods = 1
68 period = 60
79 threshold = 1
Original file line number Diff line number Diff line change 11data "aws_secretsmanager_secret_version" "identities_account_id" {
22 secret_id = aws_secretsmanager_secret. identities_account_id . name
33}
4+
5+ data "aws_secretsmanager_secret" "emails" {
6+ name = " ${ local . prefix } -emails"
7+ }
8+
9+ data "aws_secretsmanager_secret_version" "emails" {
10+ secret_id = data. aws_secretsmanager_secret . emails . id
11+ }
Original file line number Diff line number Diff line change 33 project = " nhsd-nrlf"
44 environment = terraform. workspace
55 prefix = " ${ local . project } --${ local . environment } "
6+
7+ notification_emails = nonsensitive (toset (tolist (jsondecode (data. aws_secretsmanager_secret_version . emails . secret_string ))))
68}
Original file line number Diff line number Diff line change @@ -2,6 +2,10 @@ resource "aws_secretsmanager_secret" "identities_account_id" {
22 name = " ${ local . prefix } --nhs-identities-account-id"
33}
44
5+ resource "aws_secretsmanager_secret" "notification_email_addresses" {
6+ name = " ${ local . prefix } -dev-notification-email-addresses"
7+ }
8+
59resource "aws_secretsmanager_secret" "dev_smoke_test_apigee_app" {
610 name = " ${ local . prefix } --dev--apigee-app--smoke-test"
711 description = " APIGEE App used to run Smoke Tests against the DEV environment"
Original file line number Diff line number Diff line change 11resource "aws_backup_vault_notifications" "backup_notification" {
2- count = var. notifications_target_email_address != " " ? 1 : 0
32 backup_vault_name = aws_backup_vault. main . name
4- sns_topic_arn = aws_sns_topic. backup [ 0 ] . arn
3+ sns_topic_arn = aws_sns_topic. backup . arn
54 backup_vault_events = [
65 " BACKUP_JOB_COMPLETED" ,
76 " RESTORE_JOB_COMPLETED" ,
Original file line number Diff line number Diff line change 11resource "aws_sns_topic" "backup" {
2- count = var. notifications_target_email_address != " " ? 1 : 0
32 name = " ${ local . resource_name_prefix } -notifications"
43 kms_master_key_id = var. bootstrap_kms_key_arn
54 policy = data. aws_iam_policy_document . allow_backup_to_sns . json
@@ -27,9 +26,9 @@ data "aws_iam_policy_document" "allow_backup_to_sns" {
2726}
2827
2928resource "aws_sns_topic_subscription" "aws_backup_notifications_email_target" {
30- count = var. notifications_target_email_address != " " ? 1 : 0
31- topic_arn = aws_sns_topic. backup [ 0 ] . arn
29+ for_each = var. notification_target_email_addresses
30+ topic_arn = aws_sns_topic. backup . arn
3231 protocol = " email"
33- endpoint = var . notifications_target_email_address
32+ endpoint = each . value
3433 filter_policy = jsonencode ({ " State" : [{ " anything-but" : " COMPLETED" }] })
3534}
Original file line number Diff line number Diff line change @@ -8,10 +8,10 @@ variable "environment_name" {
88 type = string
99}
1010
11- variable "notifications_target_email_address " {
12- description = " The email address to which backup notifications will be sent via SNS."
13- type = string
14- default = " "
11+ variable "notification_target_email_addresses " {
12+ description = " The email addresses to which backup notifications will be sent via SNS."
13+ type = set ( string )
14+ default = []
1515}
1616
1717variable "bootstrap_kms_key_arn" {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ resource "aws_sns_topic" "sns_topic" {
44}
55
66resource "aws_sns_topic_subscription" "sns_subscription" {
7- for_each = nonsensitive ( toset ( tolist ( jsondecode (data . aws_secretsmanager_secret_version . emails . secret_string ))))
7+ for_each = var . notification_emails
88 topic_arn = aws_sns_topic. sns_topic . arn
99 protocol = " email"
1010 endpoint = sensitive (each. value )
You can’t perform that action at this time.
0 commit comments