From 6134ae8718120f0cf4ff14058691a0f622d44b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wiktor=20Niesiob=C4=99dzki?= Date: Mon, 10 Jun 2024 07:04:20 +0000 Subject: [PATCH] Use deterministic ip_address_names to prevent failures on create or change --- terraform/slurm_cluster/modules/_slurm_instance/main.tf | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/terraform/slurm_cluster/modules/_slurm_instance/main.tf b/terraform/slurm_cluster/modules/_slurm_instance/main.tf index a54650a13..a5dfb3cd6 100644 --- a/terraform/slurm_cluster/modules/_slurm_instance/main.tf +++ b/terraform/slurm_cluster/modules/_slurm_instance/main.tf @@ -60,11 +60,13 @@ locals { for index in range(local.num_instances) : { hostname = local._hostnames[index] network_interfaces = [ - for nic in local._network_interfaces[index] : merge( + for nic_ind, nic in local._network_interfaces[index] : merge( nic, { - # generate unique name for ip address name based on hostname and first 16 characters of sha256 of (sub)network id - ip_address_name = "${local._hostnames[index]}-${substr(sha256(coalesce(nic.subnetwork, nic.network)), 0, 16)}" + # generate unique name for ip address name based on hostname and index in the list + # regrettably, can't use anything derived from network / subnetwork here, as those are known + # only after apply + ip_address_name = "${local._hostnames[index]}-nic${nic_ind}" } ) ]