fix: rediscover existing OCI VCN before subnet planning
This commit is contained in:
parent
86d2c31651
commit
5fd26fd785
|
|
@ -3697,6 +3697,21 @@ oci_foundation_reconcile_existing() {
|
|||
}
|
||||
done
|
||||
|
||||
# Recover an existing VCN when the persisted input was lost. This keeps
|
||||
# subnet CIDR derivation and all dependent resources anchored to the
|
||||
# surviving network instead of falling back to the default VCN inputs.
|
||||
if [[ -z "${LAB_OCI_EXISTING_VCN_ID:-}" && -n "${LAB_OCI_COMPARTMENT_ID:-}" ]]; then
|
||||
local discovered_vcn_id
|
||||
discovered_vcn_id="$(${oci_bin} network vcn list \
|
||||
--compartment-id "${LAB_OCI_COMPARTMENT_ID}" --all \
|
||||
--query 'data[?"display-name"==`homelab-vcn`].id | [0]' \
|
||||
--raw-output 2>/dev/null || true)"
|
||||
if [[ -n "${discovered_vcn_id}" && "${discovered_vcn_id}" != "null" ]]; then
|
||||
export LAB_OCI_EXISTING_VCN_ID="${discovered_vcn_id}"
|
||||
printf 'Reusing existing OCI VCN (%s).\n' "${discovered_vcn_id}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Existing VCNs may outlive the local state file. Use the VCN owner
|
||||
# compartment for discovery and avoid creating a duplicate Bastion.
|
||||
if truthy "${LAB_OCI_BASTION_ENABLED:-true}" && [[ -z "${LAB_OCI_BASTION_ID:-}" ]]; then
|
||||
|
|
|
|||
Loading…
Reference in New Issue