Skip to content

Commit 354a73b

Browse files
committed
pass variables to imms event lambdas
1 parent 001fbd4 commit 354a73b

File tree

3 files changed

+50
-45
lines changed

3 files changed

+50
-45
lines changed

infrastructure/instance/.terraform.lock.hcl

Lines changed: 30 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infrastructure/instance/endpoints.tf

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ data "aws_iam_policy_document" "imms_policy_document" {
5959
]
6060
}
6161

62+
data "aws_sns_topic" "fhir_api_errors" {
63+
name = "${var.environment}-fhir-api-errors"
64+
}
65+
6266
data "aws_iam_policy_document" "imms_data_quality_s3_doc" {
6367
source_policy_documents = [
6468
templatefile("${local.policy_path}/s3_data_quality_access.json", {
@@ -77,14 +81,16 @@ module "imms_event_endpoint_lambdas" {
7781
source = "./modules/lambda"
7882
count = length(local.imms_endpoints)
7983

80-
prefix = local.prefix
81-
short_prefix = local.short_prefix
82-
function_name = local.imms_endpoints[count.index]
83-
image_uri = module.docker_image.image_uri
84-
policy_json = data.aws_iam_policy_document.imms_policy_document.json
85-
environment_variables = local.imms_lambda_env_vars
86-
vpc_subnet_ids = local.private_subnet_ids
87-
vpc_security_group_ids = [data.aws_security_group.existing_securitygroup.id]
84+
prefix = local.prefix
85+
short_prefix = local.short_prefix
86+
function_name = local.imms_endpoints[count.index]
87+
image_uri = module.docker_image.image_uri
88+
policy_json = data.aws_iam_policy_document.imms_policy_document.json
89+
environment_variables = local.imms_lambda_env_vars
90+
vpc_subnet_ids = local.private_subnet_ids
91+
vpc_security_group_ids = [data.aws_security_group.existing_securitygroup.id]
92+
aws_sns_topic = data.aws_sns_topic.fhir_api_errors.arn
93+
error_alarm_notifications_enabled = var.error_alarm_notifications_enabled
8894
}
8995

9096

infrastructure/instance/modules/lambda/lambda.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,25 @@ resource "aws_cloudwatch_log_metric_filter" "max_memory_used_metric" {
5454
resource "aws_cloudwatch_log_metric_filter" "fhir_api_error_logs" {
5555
count = var.error_alarm_notifications_enabled ? 1 : 0
5656

57-
name = "${local.short_prefix}_${var.function_name}-ErrorLogsFilter"
57+
name = "${var.short_prefix}_${var.function_name}-ErrorLogsFilter"
5858
pattern = "{ $.operation_outcome.status = \"500\" || $.operation_outcome.status = \"403\" }"
5959
log_group_name = module.lambda_function_container_image.lambda_cloudwatch_log_group_name
6060

6161
metric_transformation {
62-
name = "${local.short_prefix}_${var.function_name}-ApiErrorLogs"
63-
namespace = "${local.short_prefix}-_${var.function_name}-Lambda"
62+
name = "${var.short_prefix}_${var.function_name}-ApiErrorLogs"
63+
namespace = "${var.short_prefix}_${var.function_name}-Lambda"
6464
value = "1"
6565
}
6666
}
6767

6868
resource "aws_cloudwatch_metric_alarm" "fhir_api_error_alarm" {
6969
count = var.error_alarm_notifications_enabled ? 1 : 0
7070

71-
alarm_name = "${local.short_prefix}_${var.function_name}-lambda-error"
71+
alarm_name = "${var.short_prefix}_${var.function_name}-lambda-error"
7272
comparison_operator = "GreaterThanOrEqualToThreshold"
7373
evaluation_periods = 1
74-
metric_name = "${local.short_prefix}_${var.function_name}-ErrorLogs"
75-
namespace = "${local.short_prefix}_${var.function_name}-Lambda"
74+
metric_name = "${var.short_prefix}_${var.function_name}-ErrorLogs"
75+
namespace = "${var.short_prefix}_${var.function_name}-Lambda"
7676
period = 120
7777
statistic = "Sum"
7878
threshold = 1

0 commit comments

Comments
 (0)