Skip to content

Commit f75a740

Browse files
committed
[NRL-1386] Switch lambda subscriptions to a named map
1 parent b56610a commit f75a740

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

terraform/infrastructure/locals.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ locals {
3232

3333
reporting_bucket_arn = data.aws_s3_bucket.source-data-bucket.arn
3434
reporting_kms_arn = data.aws_kms_key.glue.arn
35-
firehose_lambda_subscriptions = var.use_shared_resources ? [
36-
module.firehose__processor[0].firehose_subscription,
37-
module.firehose__processor[0].firehose_reporting_subscription
38-
] : []
35+
firehose_lambda_subscriptions = var.use_shared_resources ? {
36+
"splunk_subscription" : module.firehose__processor[0].firehose_subscription,
37+
"reports_subscription" : module.firehose__processor[0].firehose_reporting_subscription
38+
} : {}
3939
splunk_environment = local.is_sandbox_env ? "${var.account_name}sandbox" : var.account_name
4040
splunk_index = "aws_recordlocator_${local.splunk_environment}"
4141

terraform/infrastructure/modules/lambda/cloudwatch.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ resource "aws_cloudwatch_log_group" "lambda_cloudwatch_log_group" {
55
}
66

77
resource "aws_cloudwatch_log_subscription_filter" "lambda_log_filter" {
8-
name = "${aws_lambda_function.lambda_function.function_name}_filter"
9-
log_group_name = aws_cloudwatch_log_group.lambda_cloudwatch_log_group.name
8+
for_each = var.firehose_subscriptions
109

11-
count = length(var.firehose_subscriptions)
12-
role_arn = var.firehose_subscriptions[count.index].role.arn
13-
destination_arn = var.firehose_subscriptions[count.index].destination.arn
14-
filter_pattern = var.firehose_subscriptions[count.index].filter.pattern
10+
name = "${aws_lambda_function.lambda_function.function_name}_filter"
11+
log_group_name = aws_cloudwatch_log_group.lambda_cloudwatch_log_group.name
12+
role_arn = each.value.role.arn
13+
destination_arn = each.value.destination.arn
14+
filter_pattern = each.value.filter.pattern
1515
}

terraform/infrastructure/modules/lambda/vars.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ variable "additional_policies" {
2323
variable "handler" {}
2424

2525
variable "firehose_subscriptions" {
26-
default = []
26+
description = "The firehose subscriptions to attach to the lambda logs"
27+
type = map(any)
28+
default = {}
2729
}
2830

2931
variable "vpc" {

0 commit comments

Comments
 (0)