Skip to content

Commit eb1d184

Browse files
[PRMP-1579] address PR comments
1 parent 66d47fd commit eb1d184

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

infrastructure/lambda-mns-notification.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
module "mns-notification-lambda" {
2-
# count = local.is_sandbox ? 0 : 1
2+
count = 1
33
source = "./modules/lambda"
44
name = "MNSNotificationLambda"
55
handler = "handlers.mns_notification_handler.lambda_handler"
66
iam_role_policy_documents = [
7-
module.sqs-mns-notification-queue.sqs_read_policy_document,
8-
module.sqs-mns-notification-queue.sqs_write_policy_document,
7+
module.sqs-mns-notification-queue[0].sqs_read_policy_document,
8+
module.sqs-mns-notification-queue[0].sqs_write_policy_document,
99
module.lloyd_george_reference_dynamodb_table.dynamodb_write_policy_document,
1010
module.lloyd_george_reference_dynamodb_table.dynamodb_read_policy_document,
1111
aws_iam_policy.ssm_access_policy.policy,
1212
module.ndr-app-config.app_config_policy,
13-
aws_iam_policy.kms_mns_lambda_access.policy,
13+
aws_iam_policy.kms_mns_lambda_access[0].policy,
1414
]
1515
rest_api_id = null
1616
api_execution_arn = null
@@ -29,30 +29,30 @@ module "mns-notification-lambda" {
2929
}
3030

3131
resource "aws_lambda_event_source_mapping" "mns_notification_lambda" {
32-
# count = local.is_sandbox ? 0 : 1
32+
count = 1
3333
event_source_arn = module.sqs-mns-notification-queue.endpoint
3434
function_name = module.mns-notification-lambda.lambda_arn
3535
}
3636

3737
module "mns-notification-alarm" {
38-
count = local.is_sandbox ? 0 : 1
38+
count = 1
3939
source = "./modules/lambda_alarms"
4040
lambda_function_name = module.mns-notification-lambda.function_name
4141
lambda_timeout = module.mns-notification-lambda.timeout
4242
lambda_name = "mns_notification_handler"
4343
namespace = "AWS/Lambda"
44-
alarm_actions = [module.mns-notification-alarm-topic.arn]
45-
ok_actions = [module.mns-notification-alarm-topic.arn]
44+
alarm_actions = [module.mns-notification-alarm-topic[0].arn]
45+
ok_actions = [module.mns-notification-alarm-topic[0].arn]
4646
}
4747

4848
module "mns-notification-alarm-topic" {
49-
# count = local.is_sandbox ? 0 : 1
49+
count = 1
5050
source = "./modules/sns"
5151
sns_encryption_key_id = module.sns_encryption_key.id
5252
current_account_id = data.aws_caller_identity.current.account_id
5353
topic_name = "mns-notification-topic"
5454
topic_protocol = "lambda"
55-
topic_endpoint = module.mns-notification-lambda.lambda_arn
55+
topic_endpoint = module.mns-notification-lambda[0].lambda_arn
5656
delivery_policy = jsonencode({
5757
"Version" : "2012-10-17",
5858
"Statement" : [
@@ -76,7 +76,7 @@ module "mns-notification-alarm-topic" {
7676
}
7777

7878
resource "aws_iam_policy" "kms_mns_lambda_access" {
79-
# count = local.is_sandbox ? 0 : 1
79+
count = 1
8080

8181
name = "${terraform.workspace}_mns_notification_lambda_access_policy"
8282
description = "KMS policy to allow lambda to read and write MNS SQS messages"
@@ -90,7 +90,7 @@ resource "aws_iam_policy" "kms_mns_lambda_access" {
9090
"kms:GenerateDataKey"
9191
]
9292
Effect = "Allow"
93-
Resource = module.mns_encryption_key.kms_arn
93+
Resource = module.mns_encryption_key[0].kms_arn
9494
},
9595
]
9696
})

infrastructure/mns.tf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ data "aws_ssm_parameter" "mns_lambda_role" {
44

55

66
module "mns_encryption_key" {
7-
# count = local.is_sandbox ? 0 : 1
7+
count = 1
88
source = "./modules/kms"
99
kms_key_name = "alias/mns-notification-encryption-key-kms-${terraform.workspace}"
1010
kms_key_description = "Custom KMS Key to enable server side encryption for mns subscriptions"
@@ -17,7 +17,7 @@ module "mns_encryption_key" {
1717
}
1818

1919
module "sqs-mns-notification-queue" {
20-
# count = local.is_sandbox ? 0 : 1
20+
count = 1
2121
source = "./modules/sqs"
2222
name = "mns-notification-queue"
2323
max_size_message = 256 * 1024 # allow message size up to 256 KB
@@ -27,14 +27,14 @@ module "sqs-mns-notification-queue" {
2727
max_visibility = 1020
2828
delay = 60
2929
enable_sse = null
30-
kms_master_key_id = module.mns_encryption_key.id
30+
kms_master_key_id = module.mns_encryption_key[0].id
3131
enable_dlq = true
3232
}
3333

3434
resource "aws_sqs_queue_policy" "mns_sqs_access" {
35-
# count = local.is_sandbox ? 0 : 1
35+
count = 1
3636

37-
queue_url = module.sqs-mns-notification-queue.sqs_url
37+
queue_url = module.sqs-mns-notification-queue[0].sqs_url
3838

3939
policy = jsonencode({
4040
Version = "2012-10-17"
@@ -45,7 +45,7 @@ resource "aws_sqs_queue_policy" "mns_sqs_access" {
4545
AWS = data.aws_ssm_parameter.mns_lambda_role.value
4646
},
4747
Action = "SQS:SendMessage",
48-
Resource = module.sqs-mns-notification-queue.sqs_arn
48+
Resource = module.sqs-mns-notification-queue[0].sqs_arn
4949
}
5050
]
5151
})
@@ -64,7 +64,7 @@ resource "aws_cloudwatch_metric_alarm" "msn_dlq_new_message" {
6464
alarm_actions = [module.mns-dlq-alarm-topic.arn]
6565

6666
dimensions = {
67-
QueueName = module.sqs-mns-notification-queue.dlq_name
67+
QueueName = module.sqs-mns-notification-queue[0].dlq_name
6868
}
6969
}
7070

@@ -96,5 +96,5 @@ module "mns-dlq-alarm-topic" {
9696
}
9797
]
9898
})
99-
depends_on = [module.sqs-mns-notification-queue]
99+
depends_on = [module.sqs-mns-notification-queue[0]]
100100
}

0 commit comments

Comments
 (0)