Skip to content

Commit

Permalink
compliance adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvin-dnx committed Nov 13, 2024
1 parent e337ad3 commit 3c21c18
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion health-lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def lambda_handler(event, context):
sns_client = boto3.client('sns')
topic_arn = os.environ.get('SNS_TOPIC_ARN')
event_rule_name = os.environ.get('EVENT_RULE_NAME')
alarm_subject_prefix = os.environ.get('ALARM_SUBJECT_PREFIX')

# Get customer name from environment variable
customer_name = event_rule_name.split('-')[-1]
Expand All @@ -14,7 +15,7 @@ def lambda_handler(event, context):
formatted_rule_name = f"dnx-aws-health-event-{event['detail']['eventTypeCode']}-{customer_name}"

# Format the subject line with a single set of brackets
event_subject = f' ALARM: "dnx-aws-health-event-{event["detail"]["eventTypeCode"]}-{customer_name}" in {event["region"]}'
event_subject = f' ALARM: "{alarm_subject_prefix}-aws-health-event-{event["detail"]["eventTypeCode"]}-{customer_name}" in {event["region"]}'

event_message = "".join(
[
Expand Down
1 change: 1 addition & 0 deletions lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ resource "aws_lambda_function" "health_lambda" {
variables = {
SNS_TOPIC_ARN = var.sns_topic_name != "" ? aws_sns_topic.health_event_topic[0].arn : var.sns_topic_arn
EVENT_RULE_NAME = var.event_rule_name
ALARM_SUBJECT_PREFIX = var.alarm_subject_prefix
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ variable "sns_topic_arn" {
description = "Topic ARN (optional - uses an existing SNS topic)"
default = ""
}

variable "alarm_subject_prefix " {

Check warning on line 49 in variables.tf

View workflow job for this annotation

GitHub Actions / Lint

variable "alarm_subject_prefix " is declared but not used

Check warning on line 49 in variables.tf

View workflow job for this annotation

GitHub Actions / Lint

variable "alarm_subject_prefix " is declared but not used
type = string
description = "Alarm prefix name"
default = ""
}

0 comments on commit 3c21c18

Please sign in to comment.