From 1dbccecf231f147894781114de81811e5c259a2f Mon Sep 17 00:00:00 2001 From: Justin Bahr Date: Mon, 18 Nov 2024 11:56:18 -0600 Subject: [PATCH 1/7] DP-32334: add teams alert when Circuit breaker is enabled. --- ecs_fargate/ecs.tf | 20 ++++++++++++++++++++ ecs_fargate/variables.tf | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/ecs_fargate/ecs.tf b/ecs_fargate/ecs.tf index 03c9cc0..897c7d0 100644 --- a/ecs_fargate/ecs.tf +++ b/ecs_fargate/ecs.tf @@ -120,6 +120,7 @@ resource "aws_ecs_service" "main" { deployment_circuit_breaker { enable = var.ecs_circuit_breaker rollback = var.ecs_circuit_breaker + } dynamic "volume_configuration" { @@ -278,4 +279,23 @@ resource "aws_sns_topic_subscription" "cb_email_targets" { topic_arn = aws_sns_topic.cb[0].arn protocol = "email" endpoint = var.ecs_circuit_breaker_alert_email[count.index] +} + + +module "massgov_teamsalerts" { + count = var.ecs_circuit_breaker ? 1 : 0 + source = "../teamsalerts" + name = join("", [var.ecs_service_name, "Teams", "Alert"]) + human_name = "${var.ecs_cluster_name} ${var.ecs_service_name} Teams Alerts" + teams_webhook_url_param_arn = "arn:aws:ssm:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:parameter/${var.teams_webhook_param_arn}" + topic_map = [ + { + topic_arn = aws_sns_topic.cb.arn + human_name = join("", [var.ecs_cluster_name, var.ecs_service_name, "Teams", "Alert"]) + icon_url = "https://static.vecteezy.com/system/resources/previews/024/392/058/non_2x/alert-mark-failed-to-load-something-went-wrong-tap-to-retry-concept-illustration-flat-design-eps10-simple-graphic-element-for-landing-page-empty-state-ui-infographic-icon-vector.jpg" + } + ] + tags = { + "application" = "massgov-teams-notifications" + } } \ No newline at end of file diff --git a/ecs_fargate/variables.tf b/ecs_fargate/variables.tf index fd83c2b..75935cc 100644 --- a/ecs_fargate/variables.tf +++ b/ecs_fargate/variables.tf @@ -254,4 +254,8 @@ variable "ecr_repo_retention" { description = "How many images to keep in ECR Repo? [Default = 0 (disable)]" type = number default = 0 +} +variable "teams_webhook_param_arn" { + description = "Param name for Team Webhook: " + type = string } \ No newline at end of file From 27143523edc0b4903da3d7aacac1245c4971ee58 Mon Sep 17 00:00:00 2001 From: Justin Bahr Date: Tue, 19 Nov 2024 12:45:57 -0600 Subject: [PATCH 2/7] DP-32334 change module name. --- ecs_fargate/ecs.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs_fargate/ecs.tf b/ecs_fargate/ecs.tf index 897c7d0..adffb01 100644 --- a/ecs_fargate/ecs.tf +++ b/ecs_fargate/ecs.tf @@ -282,7 +282,7 @@ resource "aws_sns_topic_subscription" "cb_email_targets" { } -module "massgov_teamsalerts" { +module "teamsalerts" { count = var.ecs_circuit_breaker ? 1 : 0 source = "../teamsalerts" name = join("", [var.ecs_service_name, "Teams", "Alert"]) From dcd2a39c682be92feeccf6626e5177cd8e05c689 Mon Sep 17 00:00:00 2001 From: Justin Bahr Date: Wed, 20 Nov 2024 15:43:35 -0600 Subject: [PATCH 3/7] DP-32334 change module name. --- ecs_fargate/ecs.tf | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ecs_fargate/ecs.tf b/ecs_fargate/ecs.tf index adffb01..33f8481 100644 --- a/ecs_fargate/ecs.tf +++ b/ecs_fargate/ecs.tf @@ -295,7 +295,5 @@ module "teamsalerts" { icon_url = "https://static.vecteezy.com/system/resources/previews/024/392/058/non_2x/alert-mark-failed-to-load-something-went-wrong-tap-to-retry-concept-illustration-flat-design-eps10-simple-graphic-element-for-landing-page-empty-state-ui-infographic-icon-vector.jpg" } ] - tags = { - "application" = "massgov-teams-notifications" - } + } \ No newline at end of file From bd2743794718e5bea59a632d9fdfa92323b1d92e Mon Sep 17 00:00:00 2001 From: Justin Bahr Date: Wed, 20 Nov 2024 16:13:17 -0600 Subject: [PATCH 4/7] DP-32334 set var to default null --- ecs_fargate/variables.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/ecs_fargate/variables.tf b/ecs_fargate/variables.tf index 75935cc..5df8b61 100644 --- a/ecs_fargate/variables.tf +++ b/ecs_fargate/variables.tf @@ -258,4 +258,5 @@ variable "ecr_repo_retention" { variable "teams_webhook_param_arn" { description = "Param name for Team Webhook: " type = string + default = null } \ No newline at end of file From 05def09dc470191677ae6eecd4cf05071aa7e8d7 Mon Sep 17 00:00:00 2001 From: Justin Bahr Date: Thu, 21 Nov 2024 09:27:38 -0600 Subject: [PATCH 5/7] DP-32334 set var to default null --- ecs_fargate/ecs.tf | 2 +- ecs_fargate/variables.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ecs_fargate/ecs.tf b/ecs_fargate/ecs.tf index 33f8481..0afd9b2 100644 --- a/ecs_fargate/ecs.tf +++ b/ecs_fargate/ecs.tf @@ -283,7 +283,7 @@ resource "aws_sns_topic_subscription" "cb_email_targets" { module "teamsalerts" { - count = var.ecs_circuit_breaker ? 1 : 0 + count = var.ecs_circuit_breaker && var.teams_webhook_param_arn != "" ? 1 : 0 source = "../teamsalerts" name = join("", [var.ecs_service_name, "Teams", "Alert"]) human_name = "${var.ecs_cluster_name} ${var.ecs_service_name} Teams Alerts" diff --git a/ecs_fargate/variables.tf b/ecs_fargate/variables.tf index 5df8b61..113bd37 100644 --- a/ecs_fargate/variables.tf +++ b/ecs_fargate/variables.tf @@ -258,5 +258,5 @@ variable "ecr_repo_retention" { variable "teams_webhook_param_arn" { description = "Param name for Team Webhook: " type = string - default = null + default = "" } \ No newline at end of file From 0a34c439a03b851b67f83e60a5e72a53667eb913 Mon Sep 17 00:00:00 2001 From: Justin Bahr Date: Thu, 21 Nov 2024 10:29:14 -0600 Subject: [PATCH 6/7] DP-32334 need access to decrypt keys --- ecs_fargate/ecs.tf | 1 + ecs_fargate/variables.tf | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/ecs_fargate/ecs.tf b/ecs_fargate/ecs.tf index 0afd9b2..d157dd8 100644 --- a/ecs_fargate/ecs.tf +++ b/ecs_fargate/ecs.tf @@ -288,6 +288,7 @@ module "teamsalerts" { name = join("", [var.ecs_service_name, "Teams", "Alert"]) human_name = "${var.ecs_cluster_name} ${var.ecs_service_name} Teams Alerts" teams_webhook_url_param_arn = "arn:aws:ssm:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:parameter/${var.teams_webhook_param_arn}" + teams_webhook_url_param_key = var.teams_webhook_url_param_key topic_map = [ { topic_arn = aws_sns_topic.cb.arn diff --git a/ecs_fargate/variables.tf b/ecs_fargate/variables.tf index 113bd37..a49a884 100644 --- a/ecs_fargate/variables.tf +++ b/ecs_fargate/variables.tf @@ -259,4 +259,9 @@ variable "teams_webhook_param_arn" { description = "Param name for Team Webhook: " type = string default = "" +} +variable "teams_webhook_url_param_key" { + description = "KMS Key used for Decrypt Param:" + type = string + default = null } \ No newline at end of file From b27444a02e2d02732b2573049a31e2b8238b7f1d Mon Sep 17 00:00:00 2001 From: Justin Bahr Date: Thu, 21 Nov 2024 11:55:58 -0600 Subject: [PATCH 7/7] DP-32334 stupid counts --- ecs_fargate/ecs.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs_fargate/ecs.tf b/ecs_fargate/ecs.tf index d157dd8..be32178 100644 --- a/ecs_fargate/ecs.tf +++ b/ecs_fargate/ecs.tf @@ -291,7 +291,7 @@ module "teamsalerts" { teams_webhook_url_param_key = var.teams_webhook_url_param_key topic_map = [ { - topic_arn = aws_sns_topic.cb.arn + topic_arn = aws_sns_topic.cb[0].arn human_name = join("", [var.ecs_cluster_name, var.ecs_service_name, "Teams", "Alert"]) icon_url = "https://static.vecteezy.com/system/resources/previews/024/392/058/non_2x/alert-mark-failed-to-load-something-went-wrong-tap-to-retry-concept-illustration-flat-design-eps10-simple-graphic-element-for-landing-page-empty-state-ui-infographic-icon-vector.jpg" }