variable "enabled" { type = bool default = false } variable "region" { description = "OCI region." type = string default = "" } variable "oci_config_profile" { type = string default = "DEFAULT" } variable "tenancy_id" { description = "Tenancy OCID; used as the parent for the optional child compartment." type = string default = "" } variable "create_compartment" { type = bool default = true } variable "compartment_id" { description = "Existing compartment OCID when create_compartment is false." type = string default = "" } variable "compartment_name" { type = string default = "homelab-learning" } variable "compartment_description" { type = string default = "Jeannie-managed OCI learning resources" } variable "email_create_compartment" { type = bool default = true } variable "email_compartment_id" { type = string default = "" } variable "email_compartment_name" { type = string default = "homelab-email" } variable "vcn_display_name" { type = string default = "homelab-vcn" } variable "vcn_cidr" { type = string default = "10.50.0.0/16" } variable "public_subnet_cidr" { type = string default = "10.50.10.0/24" } variable "private_subnet_cidr" { type = string 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 default = "" } variable "existing_public_subnet_id" { description = "Existing public subnet OCID to use for newly created instances when reusing a VCN." type = string default = "" } variable "existing_email_subnet_id" { description = "Existing dedicated email subnet OCID to reuse instead of creating one." type = string default = "" } variable "email_subnet_cidr" { description = "CIDR for the dedicated public email subnet when one must be created." type = string default = "10.50.30.0/24" } variable "admin_cidr" { description = "CIDR allowed to SSH to the edge and email VMs. Do not leave this at 0.0.0.0/0." type = string default = "" } variable "open_mail_ports" { description = "Open SMTP submission, SMTP, and IMAPS ingress in the email NSG. Keep false until DNS/PTR and hardening are complete." type = bool default = false } variable "monitoring_enabled" { description = "Allow restricted node-exporter access from monitoring_cidr." type = bool default = true } variable "monitoring_cidr" { description = "CIDR allowed to scrape node-exporter; defaults to the admin CIDR." type = string default = "" } variable "backup_bucket_enabled" { description = "Create a private OCI Object Storage bucket for encrypted Jeannie backups." type = bool default = true } variable "backup_bucket_name" { description = "Object Storage bucket name for encrypted Jeannie backups." type = string default = "homelab-backups" } variable "backup_bucket_namespace" { description = "Optional Object Storage namespace override; normally discovered from the tenancy." type = string default = "" } variable "bastion_enabled" { description = "Create an OCI Bastion service for time-limited SSH sessions." type = bool default = true } variable "bastion_name" { type = string default = "homelab-bastion" } variable "bastion_target_subnet_id" { description = "Subnet the Bastion can reach; defaults to the foundation public subnet." type = string default = "" } variable "bastion_existing_id" { description = "Existing Bastion OCID to reuse instead of creating another Bastion with the same name." type = string default = "" } variable "bastion_ssh_source_cidr" { description = "CIDR allowed to SSH to managed targets from the Bastion subnet; defaults to the foundation public subnet CIDR." type = string default = "" } variable "bastion_client_cidr_block_allow_list" { description = "CIDRs allowed to create Bastion sessions; defaults to admin_cidr." type = list(string) default = [] } variable "bastion_max_session_ttl_in_seconds" { type = number default = 10800 } variable "edge_enabled" { type = bool default = true } variable "edge_existing_instance_id" { description = "Existing OCI edge instance OCID to adopt read-only instead of creating a new edge VM." type = string default = "" } variable "email_enabled" { type = bool default = true } variable "compute_enabled" { description = "Create the edge and email compute instances. Set false to test compartments and networking without consuming Always Free VM capacity." type = bool default = true } variable "edge_availability_domain" { type = string default = "" } variable "email_availability_domain" { type = string default = "" } variable "edge_image_id" { description = "OCI image OCID compatible with edge_shape." type = string default = "ocid1.image.oc1.iad.aaaaaaaarmp53tuhdoepsh4breobvmbdbq7gbmhosdogknb34xidkfi6hxjq" } variable "email_image_id" { description = "OCI image OCID compatible with email_shape." type = string default = "ocid1.image.oc1.iad.aaaaaaaarmp53tuhdoepsh4breobvmbdbq7gbmhosdogknb34xidkfi6hxjq" } variable "ssh_public_key" { type = string sensitive = true default = "" } variable "edge_shape" { type = string default = "VM.Standard.E2.1.Micro" } variable "email_shape" { type = string default = "VM.Standard.E2.1.Micro" } variable "edge_ocpus" { type = number default = 1 } variable "edge_memory_in_gbs" { type = number default = 1 } variable "email_ocpus" { type = number default = 1 } variable "email_memory_in_gbs" { type = number default = 1 } variable "edge_boot_volume_size_in_gbs" { type = number default = 50 } variable "email_boot_volume_size_in_gbs" { type = number default = 50 } variable "edge_display_name" { type = string default = "homelab-edge" } variable "email_display_name" { type = string default = "homelab-mail" } variable "edge_hostname_label" { type = string default = "homelab-edge" } variable "email_hostname_label" { type = string default = "homelab-mail" } variable "freeform_tags" { type = map(string) default = {} } check "foundation_inputs" { assert { condition = !var.enabled || ( trimspace(var.region) != "" && trimspace(var.tenancy_id) != "" && (var.create_compartment || trimspace(var.compartment_id) != "") && (!var.email_enabled || var.email_create_compartment || trimspace(var.email_compartment_id) != "") && ((trimspace(var.existing_vcn_id) == "" && trimspace(var.existing_public_subnet_id) == "") || (trimspace(var.existing_vcn_id) != "" && trimspace(var.existing_public_subnet_id) != "")) && trimspace(var.admin_cidr) != "" && (!var.compute_enabled || !var.edge_enabled || trimspace(var.edge_existing_instance_id) != "" || (trimspace(var.edge_availability_domain) != "" && trimspace(var.edge_image_id) != "")) && (!var.compute_enabled || !var.email_enabled || (trimspace(var.email_availability_domain) != "" && trimspace(var.email_image_id) != "")) && (!var.compute_enabled || trimspace(var.ssh_public_key) != "") ) error_message = "When OCI foundation is enabled, region, tenancy_id, admin_cidr, SSH key, and image/availability-domain inputs for each enabled VM are required." } assert { condition = !var.enabled || alltrue([ var.edge_ocpus > 0, var.email_ocpus > 0, var.edge_memory_in_gbs > 0, var.email_memory_in_gbs > 0, var.edge_boot_volume_size_in_gbs >= 50, var.email_boot_volume_size_in_gbs >= 50, ]) error_message = "VM CPU and memory must be positive and boot volumes must be at least 50 GB." } assert { condition = !var.enabled || ( (!var.compute_enabled || !var.edge_enabled || trimspace(var.edge_existing_instance_id) != "" || var.edge_shape == "VM.Standard.E2.1.Micro") && (!var.compute_enabled || !var.email_enabled || var.email_shape == "VM.Standard.E2.1.Micro") && (!var.compute_enabled || (var.edge_enabled && trimspace(var.edge_existing_instance_id) == "" ? var.edge_ocpus : 0) + (var.email_enabled ? var.email_ocpus : 0) <= 2) && (!var.compute_enabled || (var.edge_enabled && trimspace(var.edge_existing_instance_id) == "" ? var.edge_memory_in_gbs : 0) + (var.email_enabled ? var.email_memory_in_gbs : 0) <= 2) && (!var.compute_enabled || (var.edge_enabled && trimspace(var.edge_existing_instance_id) == "" ? var.edge_boot_volume_size_in_gbs : 0) + (var.email_enabled ? var.email_boot_volume_size_in_gbs : 0) <= 200) ) error_message = "The foundation is restricted to OCI Always Free VM.Standard.E2.1.Micro instances, at most 2 total OCPUs, 2 GB total memory, and 200 GB total boot volumes." } }