From 7e9affd72e3c5b47ac2f21b80a7e256c4a863de1 Mon Sep 17 00:00:00 2001 From: Ben Larabie Date: Thu, 17 Oct 2024 09:25:12 -0400 Subject: [PATCH] cloudwatch log groups have to stay on regardless of enable cloudwatcH (#1594) --- .../cloudwatch_logs.tf | 14 ++++---- .../cloudwatch_queries.tf | 32 +++++++++---------- aws/pinpoint_to_sqs_sms_callbacks/iam.tf | 4 +-- aws/pinpoint_to_sqs_sms_callbacks/lambda.tf | 8 ++--- aws/pinpoint_to_sqs_sms_callbacks/pools.tf | 2 +- 5 files changed, 29 insertions(+), 31 deletions(-) diff --git a/aws/pinpoint_to_sqs_sms_callbacks/cloudwatch_logs.tf b/aws/pinpoint_to_sqs_sms_callbacks/cloudwatch_logs.tf index 8144b4c18..479f2d7e2 100644 --- a/aws/pinpoint_to_sqs_sms_callbacks/cloudwatch_logs.tf +++ b/aws/pinpoint_to_sqs_sms_callbacks/cloudwatch_logs.tf @@ -3,7 +3,6 @@ # resource "aws_cloudwatch_log_group" "pinpoint_deliveries" { - count = var.cloudwatch_enabled ? 1 : 0 name = "sns/${var.region}/${var.account_id}/PinpointDirectPublishToPhoneNumber" retention_in_days = var.sensitive_log_retention_period_days tags = { @@ -12,7 +11,6 @@ resource "aws_cloudwatch_log_group" "pinpoint_deliveries" { } resource "aws_cloudwatch_log_group" "pinpoint_deliveries_failures" { - count = var.cloudwatch_enabled ? 1 : 0 name = "sns/${var.region}/${var.account_id}/PinpointDirectPublishToPhoneNumber/Failure" retention_in_days = var.sensitive_log_retention_period_days tags = { @@ -56,7 +54,7 @@ resource "aws_cloudwatch_log_metric_filter" "pinpoint-sms-blocked-as-spam" { name = "pinpoint-sms-blocked-as-spam" # See https://docs.aws.amazon.com/sms-voice/latest/userguide/configuration-sets-event-format.html pattern = "{ $.messageStatus = \"SPAM\" }" - log_group_name = aws_cloudwatch_log_group.pinpoint_deliveries_failures[0].name + log_group_name = aws_cloudwatch_log_group.pinpoint_deliveries_failures.name metric_transformation { name = "pinpoint-sms-blocked-as-spam" @@ -71,7 +69,7 @@ resource "aws_cloudwatch_log_metric_filter" "pinpoint-sms-phone-carrier-unavaila name = "pinpoint-sms-phone-carrier-unavailable" # See https://docs.aws.amazon.com/sms-voice/latest/userguide/configuration-sets-event-format.html pattern = "{ $.messageStatus = \"CARRIER_UNREACHABLE\" }" - log_group_name = aws_cloudwatch_log_group.pinpoint_deliveries_failures[0].name + log_group_name = aws_cloudwatch_log_group.pinpoint_deliveries_failures.name metric_transformation { name = "pinpoint-sms-phone-carrier-unavailable" @@ -87,7 +85,7 @@ resource "aws_cloudwatch_log_metric_filter" "pinpoint-sms-rate-exceeded" { # https://docs.aws.amazon.com/sns/latest/dg/channels-sms-originating-identities-long-codes.html # Canadian long code numbers are limited at 1 SMS per second/number pattern = "{ $.messageStatusDescription = \"Rate exceeded.\" }" - log_group_name = aws_cloudwatch_log_group.pinpoint_deliveries_failures[0].name + log_group_name = aws_cloudwatch_log_group.pinpoint_deliveries_failures.name metric_transformation { name = "pinpoint-sms-rate-exceeded" @@ -101,7 +99,7 @@ resource "aws_cloudwatch_log_metric_filter" "pinpoint-sms-successes" { count = var.cloudwatch_enabled ? 1 : 0 name = "pinpoint-sms-successes" pattern = "{ ($.isFinal IS TRUE) && ( ($.messageStatus = \"SUCCESSFUL\") || ($.messageStatus = \"DELIVERED\") ) }" - log_group_name = aws_cloudwatch_log_group.pinpoint_deliveries[0].name + log_group_name = aws_cloudwatch_log_group.pinpoint_deliveries.name metric_transformation { name = "pinpoint-sms-successes" @@ -115,7 +113,7 @@ resource "aws_cloudwatch_log_metric_filter" "pinpoint-sms-failures" { count = var.cloudwatch_enabled ? 1 : 0 name = "pinpoint-sms-failures" pattern = "{ ($.isFinal IS TRUE) && ( ($.messageStatus != \"SUCCESSFUL\") && ($.messageStatus != \"DELIVERED\") ) }" - log_group_name = aws_cloudwatch_log_group.pinpoint_deliveries_failures[0].name + log_group_name = aws_cloudwatch_log_group.pinpoint_deliveries_failures.name metric_transformation { name = "pinpoint-sms-failures" @@ -127,7 +125,7 @@ resource "aws_cloudwatch_log_metric_filter" "pinpoint-sms-failures" { resource "aws_cloudwatch_log_metric_filter" "pinpoint-sms-failures-carriers" { count = var.cloudwatch_enabled ? 1 : 0 - log_group_name = aws_cloudwatch_log_group.pinpoint_deliveries_failures[0].name + log_group_name = aws_cloudwatch_log_group.pinpoint_deliveries_failures.name name = "pinpoint-sms-failures-carriers" pattern = "{ ($.isFinal IS TRUE) && ($.carrierName != \"\" && ( ($.messageStatus != \"SUCCESSFUL\") && ($.messageStatus != \"DELIVERED\") )) }" diff --git a/aws/pinpoint_to_sqs_sms_callbacks/cloudwatch_queries.tf b/aws/pinpoint_to_sqs_sms_callbacks/cloudwatch_queries.tf index 4a03798a7..d5f1c45f7 100644 --- a/aws/pinpoint_to_sqs_sms_callbacks/cloudwatch_queries.tf +++ b/aws/pinpoint_to_sqs_sms_callbacks/cloudwatch_queries.tf @@ -3,7 +3,7 @@ resource "aws_cloudwatch_query_definition" "pinpoint-sms-blocked-as-spam" { name = "SMS (Pinpoint) / Block as spam" log_group_names = [ - aws_cloudwatch_log_group.pinpoint_deliveries_failures[0].name + aws_cloudwatch_log_group.pinpoint_deliveries_failures.name ] query_string = <