diff --git a/container-vm/main.tf b/container-vm/main.tf index 6767079..41ec1a1 100644 --- a/container-vm/main.tf +++ b/container-vm/main.tf @@ -31,13 +31,10 @@ resource "google_compute_instance_template" "container_vm_template" { boot = true } - # Network configuration + # Network configuration (private VM - no external IP) network_interface { - network = "default" - subnetwork = null - - # Assign an external IP address (access_config is required for external IP) - access_config {} + network = var.network + subnetwork = var.subnetwork } # Service Account configuration (needed for Google Cloud API access, including image pulls) diff --git a/container-vm/variables.tf b/container-vm/variables.tf index c2a8c6e..876fa93 100644 --- a/container-vm/variables.tf +++ b/container-vm/variables.tf @@ -73,3 +73,13 @@ variable "source_image_project" { default = "cos-cloud" } +variable "network" { + description = "The VPC network to attach the VM to (e.g., 'projects/PROJECT/global/networks/NETWORK' or 'NETWORK')." + type = string +} + +variable "subnetwork" { + description = "The subnetwork to attach the VM to (e.g., 'projects/PROJECT/regions/REGION/subnetworks/SUBNET' or 'SUBNET')." + type = string +} +