fix: use network-specific OCI Bastion names

This commit is contained in:
juvenal.diaz 2026-10-27 16:27:22 -06:00
parent 271703f363
commit d095d284d2
1 changed files with 8 additions and 0 deletions

View File

@ -3756,6 +3756,14 @@ oci_foundation_reconcile_existing() {
if [[ -n "${discovered_bastion_id}" && "${discovered_bastion_id}" != "null" ]]; then
export LAB_OCI_BASTION_ID="${discovered_bastion_id}"
printf 'Reusing existing OCI Bastion (%s).\n' "${discovered_bastion_id}"
elif [[ "${LAB_OCI_BASTION_NAME:-homelab-bastion}" == "homelab-bastion" && -n "${LAB_OCI_COMPARTMENT_ID:-}" ]]; then
# OCI can reject a duplicate Bastion name even when the
# existing Bastion belongs to an older network. Make the new
# Bastion name deterministic for this VCN.
local bastion_suffix
bastion_suffix="${LAB_OCI_COMPARTMENT_ID: -8}"
export LAB_OCI_BASTION_NAME="homelab-bastion-${bastion_suffix}"
printf 'Using network-specific OCI Bastion name %s.\n' "${LAB_OCI_BASTION_NAME}"
fi
fi
fi