Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPAL-1290 Remove ECS state change alarm for development #1843

Merged
merged 2 commits into from
Mar 14, 2024
Merged
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
24 changes: 23 additions & 1 deletion terraform/region/modules/region/cloudwatch.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
locals {
# Don't create ECS Task Stopped alerts in development account
enable_task_stopped_alerts = var.account_name != "development"
}
resource "aws_cloudwatch_metric_alarm" "elasticache_high_cpu_utilization" {
count = local.cache_cluster_count
actions_enabled = true
Expand Down Expand Up @@ -45,6 +49,7 @@ resource "aws_cloudwatch_metric_alarm" "elasticache_high_swap_utilization" {
}

resource "aws_cloudwatch_event_rule" "tasks_stopped" {
count = local.enable_task_stopped_alerts ? 1 : 0
name = "${local.account_name}-${local.region_name}-capture-ecs-task-stopped"
description = "Capture each task-stopped event in ECS"

Expand All @@ -66,17 +71,34 @@ resource "aws_cloudwatch_event_rule" "tasks_stopped" {
)
}

moved {
from = aws_cloudwatch_event_rule.tasks_stopped
to = aws_cloudwatch_event_rule.tasks_stopped[0]
}

resource "aws_cloudwatch_event_target" "tasks_stopped" {
rule = aws_cloudwatch_event_rule.tasks_stopped.name
count = local.enable_task_stopped_alerts ? 1 : 0
rule = aws_cloudwatch_event_rule.tasks_stopped[0].name
target_id = "SendToSNS"
arn = aws_sns_topic.cloudwatch_to_account_ops_alerts.arn
}

moved {
from = aws_cloudwatch_event_target.tasks_stopped
to = aws_cloudwatch_event_target.tasks_stopped[0]
}

resource "aws_sns_topic_policy" "task_stopped_policy" {
count = local.enable_task_stopped_alerts ? 1 : 0
arn = aws_sns_topic.cloudwatch_to_account_ops_alerts.arn
policy = data.aws_iam_policy_document.task_stopped_topic_policy.json
}

moved {
from = aws_sns_topic_policy.task_stopped_policy
to = aws_sns_topic_policy.task_stopped_policy[0]
}

data "aws_iam_policy_document" "task_stopped_topic_policy" {
statement {
effect = "Allow"
Expand Down
Loading