Skip to content

Commit 3e4ffcd

Browse files
committed
tidy up few changes
1 parent 87967e0 commit 3e4ffcd

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

infrastructure/instance/.terraform.lock.hcl

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infrastructure/instance/endpoints.tf

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ module "get_status" {
1515
function_name = "get_status"
1616
image_uri = module.docker_image.image_uri
1717
policy_json = data.aws_iam_policy_document.logs_policy_document.json
18-
aws_sns_topic = data.aws_sns_topic.fhir_api_errors.arn
1918
error_alarm_notifications_enabled = var.error_alarm_notifications_enabled
19+
environment = var.environment
2020
}
2121

2222
locals {
@@ -59,10 +59,6 @@ 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-
6662
data "aws_iam_policy_document" "imms_data_quality_s3_doc" {
6763
source_policy_documents = [
6864
templatefile("${local.policy_path}/s3_data_quality_access.json", {
@@ -89,8 +85,8 @@ module "imms_event_endpoint_lambdas" {
8985
environment_variables = local.imms_lambda_env_vars
9086
vpc_subnet_ids = local.private_subnet_ids
9187
vpc_security_group_ids = [data.aws_security_group.existing_securitygroup.id]
92-
aws_sns_topic = data.aws_sns_topic.fhir_api_errors.arn
9388
error_alarm_notifications_enabled = var.error_alarm_notifications_enabled
89+
environment = var.environment
9490
}
9591

9692

infrastructure/instance/file_name_processor.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,4 +403,4 @@ resource "aws_cloudwatch_metric_alarm" "file_name_processor_error_alarm" {
403403
alarm_description = "This sets off an alarm for any error logs found in the file name processor Lambda function"
404404
alarm_actions = [data.aws_sns_topic.batch_processor_errors.arn]
405405
treat_missing_data = "notBreaching"
406-
}
406+
}

infrastructure/instance/modules/lambda/lambda.tf

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ resource "aws_cloudwatch_log_metric_filter" "max_memory_used_metric" {
4646

4747
metric_transformation {
4848
name = "max-memory-used"
49-
namespace = var.short_prefix
49+
namespace = "${var.short_prefix}_${var.function_name}"
5050
value = "$18"
5151
}
5252
}
@@ -65,18 +65,22 @@ resource "aws_cloudwatch_log_metric_filter" "fhir_api_error_logs" {
6565
}
6666
}
6767

68+
data "aws_sns_topic" "fhir_api_errors" {
69+
name = "${var.environment}-fhir-api-errors"
70+
}
71+
6872
resource "aws_cloudwatch_metric_alarm" "fhir_api_error_alarm" {
6973
count = var.error_alarm_notifications_enabled ? 1 : 0
7074

7175
alarm_name = "${var.short_prefix}_${var.function_name}-lambda-error"
7276
comparison_operator = "GreaterThanOrEqualToThreshold"
7377
evaluation_periods = 1
74-
metric_name = "${var.short_prefix}_${var.function_name}-ErrorLogs"
78+
metric_name = "${var.short_prefix}_${var.function_name}-ApiErrorLogs"
7579
namespace = "${var.short_prefix}_${var.function_name}-Lambda"
7680
period = 120
7781
statistic = "Sum"
7882
threshold = 1
7983
alarm_description = "This sets off an alarm for any error logs found in fhir api Lambda function"
80-
alarm_actions = var.aws_sns_topic != null ? [var.aws_sns_topic] : []
84+
alarm_actions = [data.aws_sns_topic.fhir_api_errors.arn]
8185
treat_missing_data = "notBreaching"
8286
}

infrastructure/instance/modules/lambda/variables.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,8 @@ variable "function_name" {
1010
type = string
1111
}
1212

13-
variable "aws_sns_topic" {
14-
description = "SNS topic ARN for CloudWatch alarm notifications"
15-
type = string
16-
default = null
17-
}
1813
variable "error_alarm_notifications_enabled" {
19-
description = "useful switching error alerting between environment"
14+
description = "Switch to enable error alarm notifications to Slack"
2015
type = string
2116
}
2217

@@ -42,3 +37,8 @@ variable "vpc_subnet_ids" {
4237
type = list(string)
4338
default = null
4439
}
40+
41+
variable "environment" {
42+
description = "The deployment environment (e.g., dev, int, internal-qa, prod)"
43+
type = string
44+
}

0 commit comments

Comments
 (0)