diff --git a/bootstrap/oci/README.md b/bootstrap/oci/README.md index 75c9d9c..fd36bc0 100644 --- a/bootstrap/oci/README.md +++ b/bootstrap/oci/README.md @@ -34,6 +34,11 @@ Always Free compute slot, set `LAB_OCI_COMPUTE_ENABLED=false`. Edge/email subnets and security groups are still created; the VM resources are deferred until the variable is set back to `true`. +If the tenancy has exhausted its NAT gateway quota, set +`LAB_OCI_NAT_ENABLED=false` for a public-only foundation test. The private +subnet remains available but does not receive a NAT route until this is +enabled later. + For a test alongside an existing foundation, also set `LAB_OCI_FOUNDATION_STATE_FILE` to a new local state path. This prevents the test plan from treating the production foundation as resources to destroy. diff --git a/bootstrap/oci/main.tf b/bootstrap/oci/main.tf index da14fca..445cb83 100644 --- a/bootstrap/oci/main.tf +++ b/bootstrap/oci/main.tf @@ -52,7 +52,7 @@ resource "oci_core_internet_gateway" "homelab" { } resource "oci_core_nat_gateway" "homelab" { - count = var.enabled && trimspace(var.existing_vcn_id) == "" ? 1 : 0 + count = var.enabled && var.nat_gateway_enabled && trimspace(var.existing_vcn_id) == "" ? 1 : 0 compartment_id = local.target_compartment_id vcn_id = local.network_vcn_id display_name = "homelab-nat-gateway" @@ -73,7 +73,7 @@ resource "oci_core_route_table" "public" { } resource "oci_core_route_table" "private" { - count = var.enabled && trimspace(var.existing_vcn_id) == "" ? 1 : 0 + count = var.enabled && var.nat_gateway_enabled && trimspace(var.existing_vcn_id) == "" ? 1 : 0 compartment_id = local.target_compartment_id vcn_id = local.network_vcn_id display_name = "homelab-private-routes" diff --git a/bootstrap/oci/variables.tf b/bootstrap/oci/variables.tf index 784362e..bc22cf9 100644 --- a/bootstrap/oci/variables.tf +++ b/bootstrap/oci/variables.tf @@ -76,6 +76,12 @@ variable "private_subnet_cidr" { default = "10.50.20.0/24" } +variable "nat_gateway_enabled" { + description = "Create the NAT gateway and private route table. Disable for a public-only foundation test when the OCI NAT quota is exhausted." + type = bool + default = true +} + variable "existing_vcn_id" { description = "Existing VCN OCID to reuse instead of creating a VCN and its network primitives." type = string diff --git a/lib/jeannie/commands.sh b/lib/jeannie/commands.sh index 8889097..eade7ae 100644 --- a/lib/jeannie/commands.sh +++ b/lib/jeannie/commands.sh @@ -3594,7 +3594,7 @@ email_vm_manage() { oci_foundation_config_names=( LAB_OCI_FOUNDATION_ENABLED LAB_OCI_REGION LAB_OCI_TENANCY_ID LAB_OCI_ADMIN_CIDR LAB_OCI_SSH_PUBLIC_KEY LAB_OCI_CREATE_COMPARTMENT LAB_OCI_COMPARTMENT_ID - LAB_OCI_EDGE_ENABLED LAB_OCI_EMAIL_ENABLED LAB_OCI_COMPUTE_ENABLED LAB_OCI_EDGE_EXISTING_INSTANCE_ID + LAB_OCI_EDGE_ENABLED LAB_OCI_EMAIL_ENABLED LAB_OCI_COMPUTE_ENABLED LAB_OCI_NAT_ENABLED LAB_OCI_EDGE_EXISTING_INSTANCE_ID LAB_OCI_EXISTING_VCN_ID LAB_OCI_EXISTING_PUBLIC_SUBNET_ID LAB_OCI_EXISTING_EMAIL_SUBNET_ID LAB_OCI_EMAIL_CREATE_COMPARTMENT LAB_OCI_EMAIL_COMPARTMENT_ID LAB_OCI_EMAIL_COMPARTMENT_NAME LAB_OCI_EMAIL_SUBNET_CIDR LAB_OCI_EDGE_AVAILABILITY_DOMAIN LAB_OCI_EMAIL_AVAILABILITY_DOMAIN diff --git a/lib/jeannie/env.sh b/lib/jeannie/env.sh index a8a3f36..029d846 100644 --- a/lib/jeannie/env.sh +++ b/lib/jeannie/env.sh @@ -357,6 +357,7 @@ export_oci_foundation_tf_vars() { export_if_unset TF_VAR_edge_existing_instance_id "${LAB_OCI_EDGE_EXISTING_INSTANCE_ID:-}" export_if_unset TF_VAR_email_enabled "${LAB_OCI_EMAIL_ENABLED:-}" export_if_unset TF_VAR_compute_enabled "${LAB_OCI_COMPUTE_ENABLED:-}" + export_if_unset TF_VAR_nat_gateway_enabled "${LAB_OCI_NAT_ENABLED:-}" export_if_unset TF_VAR_edge_availability_domain "${LAB_OCI_EDGE_AVAILABILITY_DOMAIN:-}" export_if_unset TF_VAR_email_availability_domain "${LAB_OCI_EMAIL_AVAILABILITY_DOMAIN:-${LAB_EMAIL_AVAILABILITY_DOMAIN:-}}" export_if_unset TF_VAR_edge_image_id "${LAB_OCI_EDGE_IMAGE_ID:-}"