README.md

June 10, 2026 ยท View on GitHub

Description

This module discovers a VPC network that already exists in Google Cloud and outputs network attributes that uniquely identify it for use by other modules. The module outputs are aligned with the vpc module so that it can be used as a drop-in substitute when a VPC already exists.

For example, the blueprint below discovers the "default" global network and the "default" regional subnetwork in us-central1. With the use keyword, the vm-instance module accepts the network_self_link and subnetwork_self_link input variables that uniquely identify the network and subnetwork in which the VM will be created.

Example

- id: network1
  source: modules/network/pre-existing-vpc
  settings:
    project_id: $(vars.project_id)
    region: us-central1

- id: example_vm
  source: modules/compute/vm-instance
  use:
  - network1
  settings:
    name_prefix: example
    machine_type: c2-standard-4

NOTE: The project_id and region settings would be inferred from the deployment variables of the same name, but they are included here for clarity.

Use shared-vpc

If a network is created in different project, this module can be used to reference the network. To use a network from a different project first make sure you have a cloud nat and IAP forwarding. For more details, refer shared-vpc

License

Copyright 2026 Google LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Requirements

NameVersion
terraform>= 1.12.2
google>= 3.83

Providers

NameVersion
google>= 3.83

Modules

No modules.

Resources

NameType
google_compute_network.vpcdata source
google_compute_subnetwork.primary_subnetworkdata source

Inputs

NameDescriptionTypeDefaultRequired
network_nameName of the existing VPC networkstring"default"no
project_idProject in which the HPC deployment will be createdstringn/ayes
regionRegion in which to search for primary subnetworkstringn/ayes
subnetwork_nameName of the pre-existing VPC subnetwork; defaults to var.network_name if set to null.stringnullno

Outputs

NameDescription
network_idID of the existing VPC network
network_nameName of the existing VPC network
network_self_linkSelf link of the existing VPC network
subnetworkFull subnetwork object in the primary region
subnetwork_addressSubnetwork IP range in the primary region
subnetwork_nameName of the subnetwork in the primary region
subnetwork_self_linkSubnetwork self-link in the primary region