From 547b5dd0c39e14faa69e85f8cb28c02c462a0639 Mon Sep 17 00:00:00 2001 From: Mathew Beales Date: Fri, 2 Aug 2024 08:50:56 +0100 Subject: [PATCH] feat(terraform): add if statement to scheduled jobs --- infra/terraform/modules/service/batch.tf | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/infra/terraform/modules/service/batch.tf b/infra/terraform/modules/service/batch.tf index 4859d0d08b..2f47231994 100644 --- a/infra/terraform/modules/service/batch.tf +++ b/infra/terraform/modules/service/batch.tf @@ -75,14 +75,12 @@ locals { retry_strategy = local.default_retry_policy } } - schedules = { for job in var.batch.jobs : job.name => { - if job.schedule != "" { - description = "Schedule for ${job.name}" - schedule_expression = job.schedule - arn = "arn:aws:scheduler:::aws-sdk:batch:submitJob" - input = jsonencode({ "jobName" : "${job.name}", "jobQueue" : "vol-app-${var.environment}-default", "jobDefinition" : "arn:aws:batch:eu-west-1:054614622558:job-definition/${job.name}"}) - } - } } + schedules = { for job in var.batch.jobs : job.name => (job.schedule != "" ? { + description = "Schedule for ${job.name}" + schedule_expression = job.schedule + arn = "arn:aws:scheduler:::aws-sdk:batch:submitJob" + input = jsonencode({ "jobName" : "${job.name}", "jobQueue" : "vol-app-${var.environment}-default", "jobDefinition" : "arn:aws:batch:eu-west-1:054614622558:job-definition/${job.name}"}) + } : null) } } module "batch" {