From f32544667ec6fed51dbdae2fd7af429f43fd56d6 Mon Sep 17 00:00:00 2001 From: Aditya Sridhar Date: Thu, 14 Sep 2023 14:47:54 -0400 Subject: [PATCH 1/4] chore: add featureflag for new search notification --- packages/server/src/index.js | 11 ++++++++++- terraform/main.tf | 1 + terraform/modules/gost_api/task.tf | 1 + terraform/modules/gost_api/variables.tf | 6 ++++++ terraform/prod.tfvars | 2 +- terraform/sandbox.tfvars | 2 +- terraform/staging.tfvars | 2 +- terraform/variables.tf | 4 ++++ 8 files changed, 25 insertions(+), 4 deletions(-) diff --git a/packages/server/src/index.js b/packages/server/src/index.js index 21abf3598..be40e287b 100755 --- a/packages/server/src/index.js +++ b/packages/server/src/index.js @@ -29,7 +29,16 @@ if (process.env.ENABLE_GRANTS_SCRAPER === 'true') { if (process.env.ENABLE_GRANTS_DIGEST === 'true') { const generateGrantDigestCron = new CronJob( // once per day at 12:00 UTC - '0 0 12 * * *', emailService.buildAndSendUserSavedSearchGrantDigest, + '0 0 12 * * *', emailService.buildAndSendGrantDigest, + ); + generateGrantDigestCron.start(); +} + +if (process.env.ENABLE_SAVED_SEARCH_GRANTS_DIGEST === 'true') { + const generateGrantDigestCron = new CronJob( + // once per day at 13:00 UTC + // one hour after the old grant digest + '0 0 13 * * *', emailService.buildAndSendUserSavedSearchGrantDigest, ); generateGrantDigestCron.start(); } diff --git a/terraform/main.tf b/terraform/main.tf index e7e63805e..c49d7acdb 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -127,6 +127,7 @@ module "api" { autoscaling_desired_count_maximum = var.api_maximum_task_count enable_grants_scraper = var.api_enable_grants_scraper enable_grants_digest = var.api_enable_grants_digest + enable_saved_search_grants_digest = var.api_enable_saved_search_grants_digest unified_service_tags = local.unified_service_tags datadog_environment_variables = var.api_datadog_environment_variables diff --git a/terraform/modules/gost_api/task.tf b/terraform/modules/gost_api/task.tf index 7f63ed025..175e5cdc3 100644 --- a/terraform/modules/gost_api/task.tf +++ b/terraform/modules/gost_api/task.tf @@ -48,6 +48,7 @@ module "api_container_definition" { AUDIT_REPORT_BUCKET = module.arpa_audit_reports_bucket.bucket_id DATA_DIR = "/var/data" ENABLE_GRANTS_DIGEST = var.enable_grants_digest ? "true" : "false" + ENABLE_SAVED_SEARCH_GRANTS_DIGEST = var.enable_saved_search_grants_digest ? "true" : "false" ENABLE_GRANTS_SCRAPER = "false" GRANTS_SCRAPER_DATE_RANGE = 7 GRANTS_SCRAPER_DELAY = 1000 diff --git a/terraform/modules/gost_api/variables.tf b/terraform/modules/gost_api/variables.tf index b88ea50bd..235b62cf3 100644 --- a/terraform/modules/gost_api/variables.tf +++ b/terraform/modules/gost_api/variables.tf @@ -168,6 +168,12 @@ variable "enable_grants_digest" { default = false } +variable "enable_saved_search_grants_digest" { + description = "When true, sets the ENABLE_SAVED_SEARCH_GRANTS_DIGEST environment variable to true in the API container." + type = bool + default = false +} + variable "unified_service_tags" { description = "Datadog unified service tags to apply to runtime environments." type = object({ diff --git a/terraform/prod.tfvars b/terraform/prod.tfvars index 122de4605..85a95da6c 100644 --- a/terraform/prod.tfvars +++ b/terraform/prod.tfvars @@ -44,7 +44,7 @@ api_default_desired_task_count = 3 api_minumum_task_count = 2 api_maximum_task_count = 5 api_enable_grants_scraper = true -api_enable_grants_digest = true +api_enable_saved_search_grants_digest = true api_log_retention_in_days = 30 api_datadog_environment_variables = { DD_PROFILING_ENABLED = true, diff --git a/terraform/sandbox.tfvars b/terraform/sandbox.tfvars index edd235b15..16bb86f17 100644 --- a/terraform/sandbox.tfvars +++ b/terraform/sandbox.tfvars @@ -23,7 +23,7 @@ api_default_desired_task_count = 1 api_minumum_task_count = 1 api_maximum_task_count = 5 api_enable_grants_scraper = false -api_enable_grants_digest = false +api_enable_saved_search_grants_digest = false api_log_retention_in_days = 7 // Postgres diff --git a/terraform/staging.tfvars b/terraform/staging.tfvars index 06cb84d85..6a5baea1a 100644 --- a/terraform/staging.tfvars +++ b/terraform/staging.tfvars @@ -44,7 +44,7 @@ api_default_desired_task_count = 1 api_minumum_task_count = 1 api_maximum_task_count = 5 api_enable_grants_scraper = false -api_enable_grants_digest = false +api_enable_saved_search_grants_digest = false api_log_retention_in_days = 14 api_datadog_environment_variables = { DD_PROFILING_ENABLED = true, diff --git a/terraform/variables.tf b/terraform/variables.tf index 0148e9936..aba7df821 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -119,6 +119,10 @@ variable "api_enable_grants_digest" { type = bool } +variable "api_enable_saved_search_grants_digest" { + type = bool +} + variable "api_log_retention_in_days" { type = number } From 88842443b71430d69e2ef0bc98e17e0df4c1a93a Mon Sep 17 00:00:00 2001 From: Aditya Sridhar Date: Thu, 14 Sep 2023 14:51:10 -0400 Subject: [PATCH 2/4] fix: restores old env vars --- terraform/prod.tfvars | 17 +++++++++-------- terraform/sandbox.tfvars | 17 +++++++++-------- terraform/staging.tfvars | 17 +++++++++-------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/terraform/prod.tfvars b/terraform/prod.tfvars index 85a95da6c..da6d847fe 100644 --- a/terraform/prod.tfvars +++ b/terraform/prod.tfvars @@ -38,14 +38,15 @@ website_feature_flags = { cluster_container_insights_enabled = true // API / Backend -api_enabled = true -api_container_image_tag = "stable" -api_default_desired_task_count = 3 -api_minumum_task_count = 2 -api_maximum_task_count = 5 -api_enable_grants_scraper = true -api_enable_saved_search_grants_digest = true -api_log_retention_in_days = 30 +api_enabled = true +api_container_image_tag = "stable" +api_default_desired_task_count = 3 +api_minumum_task_count = 2 +api_maximum_task_count = 5 +api_enable_grants_scraper = true +api_enable_grants_digest = true +api_enable_saved_search_grants_digest = false +api_log_retention_in_days = 30 api_datadog_environment_variables = { DD_PROFILING_ENABLED = true, } diff --git a/terraform/sandbox.tfvars b/terraform/sandbox.tfvars index 16bb86f17..0ceab2cff 100644 --- a/terraform/sandbox.tfvars +++ b/terraform/sandbox.tfvars @@ -17,14 +17,15 @@ website_feature_flags = { cluster_container_insights_enabled = false // API / Backend -api_enabled = true -api_container_image_tag = "latest" -api_default_desired_task_count = 1 -api_minumum_task_count = 1 -api_maximum_task_count = 5 -api_enable_grants_scraper = false -api_enable_saved_search_grants_digest = false -api_log_retention_in_days = 7 +api_enabled = true +api_container_image_tag = "latest" +api_default_desired_task_count = 1 +api_minumum_task_count = 1 +api_maximum_task_count = 5 +api_enable_grants_scraper = false +api_enable_grants_digest = false +api_enable_saved_search_grants_digest = false +api_log_retention_in_days = 7 // Postgres postgres_enabled = true diff --git a/terraform/staging.tfvars b/terraform/staging.tfvars index 6a5baea1a..791286840 100644 --- a/terraform/staging.tfvars +++ b/terraform/staging.tfvars @@ -38,14 +38,15 @@ website_feature_flags = { cluster_container_insights_enabled = true // API / Backend -api_enabled = true -api_container_image_tag = "latest" -api_default_desired_task_count = 1 -api_minumum_task_count = 1 -api_maximum_task_count = 5 -api_enable_grants_scraper = false -api_enable_saved_search_grants_digest = false -api_log_retention_in_days = 14 +api_enabled = true +api_container_image_tag = "latest" +api_default_desired_task_count = 1 +api_minumum_task_count = 1 +api_maximum_task_count = 5 +api_enable_grants_scraper = false +api_enable_grants_digest = false +api_enable_saved_search_grants_digest = true +api_log_retention_in_days = 14 api_datadog_environment_variables = { DD_PROFILING_ENABLED = true, } From cd7a56d7aa1a3681d2a836bde166bbed460f6250 Mon Sep 17 00:00:00 2001 From: Aditya Sridhar Date: Thu, 14 Sep 2023 14:52:26 -0400 Subject: [PATCH 3/4] fix: var name --- packages/server/src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/src/index.js b/packages/server/src/index.js index be40e287b..de6395df5 100755 --- a/packages/server/src/index.js +++ b/packages/server/src/index.js @@ -35,12 +35,12 @@ if (process.env.ENABLE_GRANTS_DIGEST === 'true') { } if (process.env.ENABLE_SAVED_SEARCH_GRANTS_DIGEST === 'true') { - const generateGrantDigestCron = new CronJob( + const generateSavedSearchGrantDigestCron = new CronJob( // once per day at 13:00 UTC // one hour after the old grant digest '0 0 13 * * *', emailService.buildAndSendUserSavedSearchGrantDigest, ); - generateGrantDigestCron.start(); + generateSavedSearchGrantDigestCron.start(); } const cleanGeneratedPdfCron = new CronJob( From 304cd0133d3b27739332ebb7aa3eab3cb9795dd2 Mon Sep 17 00:00:00 2001 From: Aditya Sridhar Date: Thu, 14 Sep 2023 14:55:06 -0400 Subject: [PATCH 4/4] fix: formatting terraform --- terraform/main.tf | 2 +- terraform/modules/gost_api/task.tf | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index c49d7acdb..80d551fd7 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -127,7 +127,7 @@ module "api" { autoscaling_desired_count_maximum = var.api_maximum_task_count enable_grants_scraper = var.api_enable_grants_scraper enable_grants_digest = var.api_enable_grants_digest - enable_saved_search_grants_digest = var.api_enable_saved_search_grants_digest + enable_saved_search_grants_digest = var.api_enable_saved_search_grants_digest unified_service_tags = local.unified_service_tags datadog_environment_variables = var.api_datadog_environment_variables diff --git a/terraform/modules/gost_api/task.tf b/terraform/modules/gost_api/task.tf index 175e5cdc3..20474bba9 100644 --- a/terraform/modules/gost_api/task.tf +++ b/terraform/modules/gost_api/task.tf @@ -44,19 +44,19 @@ module "api_container_definition" { map_environment = merge( { - API_DOMAIN = "https://${var.domain_name}" - AUDIT_REPORT_BUCKET = module.arpa_audit_reports_bucket.bucket_id - DATA_DIR = "/var/data" - ENABLE_GRANTS_DIGEST = var.enable_grants_digest ? "true" : "false" - ENABLE_SAVED_SEARCH_GRANTS_DIGEST = var.enable_saved_search_grants_digest ? "true" : "false" - ENABLE_GRANTS_SCRAPER = "false" - GRANTS_SCRAPER_DATE_RANGE = 7 - GRANTS_SCRAPER_DELAY = 1000 - NODE_OPTIONS = "--max_old_space_size=1024" - NOTIFICATIONS_EMAIL = var.notifications_email_address - PGSSLROOTCERT = "rds-combined-ca-bundle.pem" - VUE_APP_GRANTS_API_URL = module.api_gateway.apigatewayv2_api_api_endpoint - WEBSITE_DOMAIN = "https://${var.website_domain_name}" + API_DOMAIN = "https://${var.domain_name}" + AUDIT_REPORT_BUCKET = module.arpa_audit_reports_bucket.bucket_id + DATA_DIR = "/var/data" + ENABLE_GRANTS_DIGEST = var.enable_grants_digest ? "true" : "false" + ENABLE_SAVED_SEARCH_GRANTS_DIGEST = var.enable_saved_search_grants_digest ? "true" : "false" + ENABLE_GRANTS_SCRAPER = "false" + GRANTS_SCRAPER_DATE_RANGE = 7 + GRANTS_SCRAPER_DELAY = 1000 + NODE_OPTIONS = "--max_old_space_size=1024" + NOTIFICATIONS_EMAIL = var.notifications_email_address + PGSSLROOTCERT = "rds-combined-ca-bundle.pem" + VUE_APP_GRANTS_API_URL = module.api_gateway.apigatewayv2_api_api_endpoint + WEBSITE_DOMAIN = "https://${var.website_domain_name}" }, local.datadog_env_vars, var.api_container_environment,