Skip to content

Commit

Permalink
Use deterministic ip_address_names to prevent failures on create or c…
Browse files Browse the repository at this point in the history
…hange
  • Loading branch information
wiktorn committed Aug 6, 2024
1 parent fc496c9 commit 449951d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions terraform/slurm_cluster/modules/_slurm_instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
)
]
Expand Down

0 comments on commit 449951d

Please sign in to comment.