Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ def get_affected_entities(health_client, event_arn, affected_accounts, is_org_mo
# don't list entities which are accounts (handled separately for chat applications)
def get_resources_from_entities(affected_entity_array):
resources = []
filter_resolved = os.environ.get("FILTER_RESOLVED", "false") == "true"

for entity in affected_entity_array:
if entity["entityValue"] == "UNKNOWN":
Expand All @@ -465,6 +466,7 @@ def get_resources_from_entities(affected_entity_array):
elif (
entity["entityValue"] != "AWS_ACCOUNT"
and entity["entityValue"] != entity["awsAccountId"]
and (not filter_resolved or entity.get("status", "").lower() != "resolved")
):
resources.append(entity["entityValue"])
return resources
Expand Down
7 changes: 7 additions & 0 deletions terraform/Terraform_DEPLOY_AHA/Terraform_DEPLOY_AHA.tf
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ variable "ExcludeAccountIDs" {
default = ""
description = "If you would like to EXCLUDE any accounts from alerting, enter a .csv filename created with comma-seperated account numbers. Sample AccountIDs file name: aha_account_ids.csv. If not, leave the default empty."
}
variable "FilterResolvedResources" {
type = bool
default = false
description = "Whether to filter out resources with resolved status. Set to true to filter out resolved resources, false to show all resources."
}

##### Resources for AHA Solution created below.

Expand Down Expand Up @@ -684,6 +689,7 @@ resource "aws_lambda_function" "AHA-LambdaFunction-PrimaryRegion" {
"MANAGEMENT_ROLE_ARN" = var.ManagementAccountRoleArn == "" ? "None" : var.ManagementAccountRoleArn
"ACCOUNT_IDS" = var.ExcludeAccountIDs
"S3_BUCKET" = join("",aws_s3_bucket.AHA-S3Bucket-PrimaryRegion[*].bucket)
"FILTER_RESOLVED" = var.FilterResolvedResources
}
}

Expand Down Expand Up @@ -735,6 +741,7 @@ resource "aws_lambda_function" "AHA-LambdaFunction-SecondaryRegion" {
"MANAGEMENT_ROLE_ARN" = var.ManagementAccountRoleArn
"ACCOUNT_IDS" = var.ExcludeAccountIDs
"S3_BUCKET" = join("",aws_s3_bucket.AHA-S3Bucket-SecondaryRegion[*].bucket)
"FILTER_RESOLVED" = var.FilterResolvedResources
}
}

Expand Down
1 change: 1 addition & 0 deletions terraform/Terraform_DEPLOY_AHA/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ EventSearchBack="1"
Regions="all regions"
ManagementAccountRoleArn=""
ExcludeAccountIDs=""
FilterResolvedResources=false

# Tags applied to all resources - using module provider. Update them per your requirement.
default_tags = {
Expand Down