From 42c09a1c18c44fdf0e6495f7db0bc1d27ab8eb31 Mon Sep 17 00:00:00 2001 From: InAnYan Date: Sat, 8 Aug 2026 09:16:26 +0200 Subject: [PATCH] feat: add health check --- main.tf | 6 ++++-- variables.tf | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index e5d9981..5e90685 100644 --- a/main.tf +++ b/main.tf @@ -7,7 +7,8 @@ resource "terraform_data" "docker_compose_deploy" { var.vm_ip, dirname(var.destination_path), var.ssh_user, - var.start_delay_seconds + var.start_delay_seconds, + var.health_check_command ] connection { @@ -30,7 +31,8 @@ resource "terraform_data" "docker_compose_deploy" { "export INFISICAL_API_URL=\"https://secrets.itlab-ffeks.dnu.edu.ua\"", "export INFISICAL_DISABLE_UPDATE_CHECK=true", "infisical run --env=\"${self.triggers_replace[2]}\" -- docker compose up -d", - "sleep ${self.triggers_replace[7]}" + "sleep ${self.triggers_replace[7]}", + self.triggers_replace[8] != "" ? "timeout 60s bash -c 'until ${self.triggers_replace[8]}; do sleep 1; done'" : "true" ] } diff --git a/variables.tf b/variables.tf index 090beb2..b64bdb6 100644 --- a/variables.tf +++ b/variables.tf @@ -43,3 +43,10 @@ variable "start_delay_seconds" { default = 10 } +variable "health_check_command" { + type = string + description = "Optional health check command to run on the VM to wait for the service to be ready" + default = "" +} + +