From 6a105c2fce35c7bea58c78a8bc56917e623d80f4 Mon Sep 17 00:00:00 2001 From: Kiara Grouwstra Date: Sun, 13 Apr 2025 21:44:14 +0200 Subject: [PATCH] null_resource -> terraform_data --- launch/main.tf | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/launch/main.tf b/launch/main.tf index cafd0eb2..14a4116d 100644 --- a/launch/main.tf +++ b/launch/main.tf @@ -98,19 +98,26 @@ data "external" "hash" { program = ["echo", "{\"hash\":\"$(nix-hash ..)\"}"] } -# merge instantiate/deploy, cuz i don't want 24+s instantiates when nothing changed. +# merged instantiate/deploy to prevent 24+s instantiates when nothing changed. # terraform-nixos separates these to only deploy if instantiate changed. # FIXME find a better solution for this. current considerations were: -# - `resource null_resource` cannot have outputs, while we want info from the instantiation (unless built on host?). -# - `data external` always runs, which is undesirable for steps like deploy/instantiation. -# FIXME null_resource docs recommend terraform_data over null_resource -resource "null_resource" "deploy_nixos" { +# - generic resources cannot have outputs, while we want info from the instantiation (unless built on host?). +# - `data` always runs, which is slow for deploy/instantiation. +resource "terraform_data" "nixos" { for_each = {for name, inst in merge( local.peripherals, local.applications, ) : name => inst if inst.cfg.enable} - triggers = data.external.hash.result + triggers_replace = [ + data.external.hash.result, + var.deploy_environment, + var.domain, + var.initialUser, + local.system, + each.key, + each.value, + ] provisioner "local-exec" { working_dir = path.root