@@ -29,20 +29,16 @@ provider "aws" {
2929locals {
3030 source_files = [" ${ path . module } /../../handler.py" , " ${ path . module } /../../messagegenerator.py" ]
3131}
32- data "template_file" "t_file" {
33- count = " ${ length (local. source_files )} "
34- template = " ${ file (element (local. source_files , count. index ))} "
35- }
3632data "archive_file" "lambda_zip" {
3733 type = " zip"
3834 output_path = " ${ path . module } /lambda_function.zip"
3935 source {
4036 filename = " ${ basename (local. source_files [0 ])} "
41- content = " ${ data . template_file . t_file . 0 . rendered } "
37+ content = file ( " ${ local . source_files [ 0 ] } " )
4238 }
4339 source {
4440 filename = " ${ basename (local. source_files [1 ])} "
45- content = " ${ data . template_file . t_file . 1 . rendered } "
41+ content = file ( " ${ local . source_files [ 1 ] } " )
4642 }
4743}
4844
@@ -673,6 +669,10 @@ resource "aws_lambda_function" "AHA-LambdaFunction-PrimaryRegion" {
673669
674670 environment {
675671 variables = {
672+ " Slack" = var.SlackWebhookURL != " " ? " True" : null
673+ " Team" = var.MicrosoftTeamsWebhookURL != " " ? " True" : null
674+ " Chime" = var.AmazonChimeWebhookURL != " " ? " True" : null
675+ " Eventbridge" = var.EventBusName != " " ? " True" : null
676676 " DYNAMODB_TABLE" = " ${ var . dynamodbtable } -${ random_string . resource_code . result } "
677677 " EMAIL_SUBJECT" = var.Subject
678678 " EVENT_SEARCH_BACK" = var.EventSearchBack
@@ -681,7 +681,7 @@ resource "aws_lambda_function" "AHA-LambdaFunction-PrimaryRegion" {
681681 " ORG_STATUS" = var.AWSOrganizationsEnabled
682682 " REGIONS" = var.Regions
683683 " TO_EMAIL" = var.ToEmail
684- " MANAGEMENT_ROLE_ARN" = var.ManagementAccountRoleArn
684+ " MANAGEMENT_ROLE_ARN" = var.ManagementAccountRoleArn == " " ? " None " : var.ManagementAccountRoleArn
685685 " ACCOUNT_IDS" = var.ExcludeAccountIDs
686686 " S3_BUCKET" = join (" " ,aws_s3_bucket. AHA-S3Bucket-PrimaryRegion [* ]. bucket )
687687 }
@@ -720,6 +720,10 @@ resource "aws_lambda_function" "AHA-LambdaFunction-SecondaryRegion" {
720720
721721 environment {
722722 variables = {
723+ " Slack" = var.SlackWebhookURL != " " ? " True" : null
724+ " Team" = var.MicrosoftTeamsWebhookURL != " " ? " True" : null
725+ " Chime" = var.AmazonChimeWebhookURL != " " ? " True" : null
726+ " Eventbridge" = var.EventBusName != " " ? " True" : null
723727 " DYNAMODB_TABLE" = " ${ var . dynamodbtable } -${ random_string . resource_code . result } "
724728 " EMAIL_SUBJECT" = var.Subject
725729 " EVENT_SEARCH_BACK" = var.EventSearchBack
@@ -752,19 +756,19 @@ resource "aws_lambda_function" "AHA-LambdaFunction-SecondaryRegion" {
752756resource "aws_cloudwatch_event_rule" "AHA-LambdaSchedule-PrimaryRegion" {
753757 description = " Lambda trigger Event"
754758 event_bus_name = " default"
755- is_enabled = true
759+ state = " ENABLED "
756760 name = " AHA-LambdaSchedule-${ random_string . resource_code . result } "
757761 schedule_expression = " rate(1 minute)"
758762 tags = {
759763 " Name" = " AHA-LambdaSchedule"
760764 }
761765}
762766resource "aws_cloudwatch_event_rule" "AHA-LambdaSchedule-SecondaryRegion" {
767+ description = " Lambda trigger Event"
763768 count = " ${ var . aha_secondary_region == " " ? 0 : 1 } "
764769 provider = aws. secondary_region
765- description = " Lambda trigger Event"
766770 event_bus_name = " default"
767- is_enabled = true
771+ state = " ENABLED "
768772 name = " AHA-LambdaSchedule-${ random_string . resource_code . result } "
769773 schedule_expression = " rate(1 minute)"
770774 tags = {
0 commit comments