From c83c6c340c85c4e612b623d905708d82e33d7a0f Mon Sep 17 00:00:00 2001 From: Abdelhak Marouane Date: Wed, 12 Jun 2024 15:55:28 -0500 Subject: [PATCH] Configure cloudwatch logs retention days for the workers --- infrastructure/ecs_services/airflow_worker.tf | 3 ++- infrastructure/ecs_services/varaibles.tf | 4 ++++ infrastructure/main.tf | 1 + infrastructure/varaibles.tf | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/infrastructure/ecs_services/airflow_worker.tf b/infrastructure/ecs_services/airflow_worker.tf index ad2c4a1..08f6d3f 100644 --- a/infrastructure/ecs_services/airflow_worker.tf +++ b/infrastructure/ecs_services/airflow_worker.tf @@ -1,7 +1,8 @@ # Send worker logs to this Cloud Watch log group + resource "aws_cloudwatch_log_group" "airflow_worker" { name_prefix = "/${var.prefix}/airflow-worker/" - retention_in_days = 1 + retention_in_days = var.workers_logs_retention_days } diff --git a/infrastructure/ecs_services/varaibles.tf b/infrastructure/ecs_services/varaibles.tf index 7f55520..6e99096 100644 --- a/infrastructure/ecs_services/varaibles.tf +++ b/infrastructure/ecs_services/varaibles.tf @@ -98,3 +98,7 @@ variable "worker_cmd" { variable "subdomain" { } + +variable "workers_logs_retention_days" { + type = number +} diff --git a/infrastructure/main.tf b/infrastructure/main.tf index 228d12a..b53c32f 100644 --- a/infrastructure/main.tf +++ b/infrastructure/main.tf @@ -91,6 +91,7 @@ module "ecs_services" { stage = var.stage worker_cmd = var.worker_cmd subdomain = var.subdomain + workers_logs_retention_days = var.workers_logs_retention_days } resource "null_resource" "airflow_create_airflow_user" { diff --git a/infrastructure/varaibles.tf b/infrastructure/varaibles.tf index 4a8e2c3..1d4dd6a 100644 --- a/infrastructure/varaibles.tf +++ b/infrastructure/varaibles.tf @@ -178,4 +178,9 @@ variable "rds_max_allocated_storage" { variable "extra_airflow_configuration" { type = map(any) default = {} +} + +variable "workers_logs_retention_days" { + type = number + default = 1 } \ No newline at end of file