1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. compute
  5. getSubnetworks
Google Cloud v8.25.1 published on Wednesday, Apr 9, 2025 by Pulumi

gcp.compute.getSubnetworks

Explore with Pulumi AI

Google Cloud v8.25.1 published on Wednesday, Apr 9, 2025 by Pulumi

Get subnetworks within GCE. See the official documentation and API.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const my_subnetworks = gcp.compute.getSubnetworks({
    filter: "ipCidrRange eq 192.168.178.0/24",
    project: "my-project",
    region: "us-east1",
});
Copy
import pulumi
import pulumi_gcp as gcp

my_subnetworks = gcp.compute.get_subnetworks(filter="ipCidrRange eq 192.168.178.0/24",
    project="my-project",
    region="us-east1")
Copy
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.GetSubnetworks(ctx, &compute.GetSubnetworksArgs{
			Filter:  pulumi.StringRef("ipCidrRange eq 192.168.178.0/24"),
			Project: pulumi.StringRef("my-project"),
			Region:  pulumi.StringRef("us-east1"),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var my_subnetworks = Gcp.Compute.GetSubnetworks.Invoke(new()
    {
        Filter = "ipCidrRange eq 192.168.178.0/24",
        Project = "my-project",
        Region = "us-east1",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.ComputeFunctions;
import com.pulumi.gcp.compute.inputs.GetSubnetworksArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var my-subnetworks = ComputeFunctions.getSubnetworks(GetSubnetworksArgs.builder()
            .filter("ipCidrRange eq 192.168.178.0/24")
            .project("my-project")
            .region("us-east1")
            .build());

    }
}
Copy
variables:
  my-subnetworks:
    fn::invoke:
      function: gcp:compute:getSubnetworks
      arguments:
        filter: ipCidrRange eq 192.168.178.0/24
        project: my-project
        region: us-east1
Copy

Using getSubnetworks

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getSubnetworks(args: GetSubnetworksArgs, opts?: InvokeOptions): Promise<GetSubnetworksResult>
function getSubnetworksOutput(args: GetSubnetworksOutputArgs, opts?: InvokeOptions): Output<GetSubnetworksResult>
Copy
def get_subnetworks(filter: Optional[str] = None,
                    project: Optional[str] = None,
                    region: Optional[str] = None,
                    opts: Optional[InvokeOptions] = None) -> GetSubnetworksResult
def get_subnetworks_output(filter: Optional[pulumi.Input[str]] = None,
                    project: Optional[pulumi.Input[str]] = None,
                    region: Optional[pulumi.Input[str]] = None,
                    opts: Optional[InvokeOptions] = None) -> Output[GetSubnetworksResult]
Copy
func GetSubnetworks(ctx *Context, args *GetSubnetworksArgs, opts ...InvokeOption) (*GetSubnetworksResult, error)
func GetSubnetworksOutput(ctx *Context, args *GetSubnetworksOutputArgs, opts ...InvokeOption) GetSubnetworksResultOutput
Copy

> Note: This function is named GetSubnetworks in the Go SDK.

public static class GetSubnetworks 
{
    public static Task<GetSubnetworksResult> InvokeAsync(GetSubnetworksArgs args, InvokeOptions? opts = null)
    public static Output<GetSubnetworksResult> Invoke(GetSubnetworksInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetSubnetworksResult> getSubnetworks(GetSubnetworksArgs args, InvokeOptions options)
public static Output<GetSubnetworksResult> getSubnetworks(GetSubnetworksArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: gcp:compute/getSubnetworks:getSubnetworks
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Filter string
A string filter as defined in the REST API.
Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Region string
The region this subnetwork has been created in. If unspecified, this defaults to the region configured in the provider.
Filter string
A string filter as defined in the REST API.
Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Region string
The region this subnetwork has been created in. If unspecified, this defaults to the region configured in the provider.
filter String
A string filter as defined in the REST API.
project String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
region String
The region this subnetwork has been created in. If unspecified, this defaults to the region configured in the provider.
filter string
A string filter as defined in the REST API.
project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
region string
The region this subnetwork has been created in. If unspecified, this defaults to the region configured in the provider.
filter str
A string filter as defined in the REST API.
project str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
region str
The region this subnetwork has been created in. If unspecified, this defaults to the region configured in the provider.
filter String
A string filter as defined in the REST API.
project String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
region String
The region this subnetwork has been created in. If unspecified, this defaults to the region configured in the provider.

getSubnetworks Result

The following output properties are available:

Id string
The provider-assigned unique ID for this managed resource.
Subnetworks List<GetSubnetworksSubnetwork>
A list of all retrieved GCE subnetworks. Structure is defined below.
Filter string
Project string
Region string
Id string
The provider-assigned unique ID for this managed resource.
Subnetworks []GetSubnetworksSubnetwork
A list of all retrieved GCE subnetworks. Structure is defined below.
Filter string
Project string
Region string
id String
The provider-assigned unique ID for this managed resource.
subnetworks List<GetSubnetworksSubnetwork>
A list of all retrieved GCE subnetworks. Structure is defined below.
filter String
project String
region String
id string
The provider-assigned unique ID for this managed resource.
subnetworks GetSubnetworksSubnetwork[]
A list of all retrieved GCE subnetworks. Structure is defined below.
filter string
project string
region string
id str
The provider-assigned unique ID for this managed resource.
subnetworks Sequence[GetSubnetworksSubnetwork]
A list of all retrieved GCE subnetworks. Structure is defined below.
filter str
project str
region str
id String
The provider-assigned unique ID for this managed resource.
subnetworks List<Property Map>
A list of all retrieved GCE subnetworks. Structure is defined below.
filter String
project String
region String

Supporting Types

GetSubnetworksSubnetwork

Description This property is required. string
Description of the subnetwork.
IpCidrRange This property is required. string
The IP address range represented as a CIDR block.
Name This property is required. string
The name of the subnetwork.
Network This property is required. string
The self link of the parent network.
NetworkSelfLink This property is required. string
PrivateIpGoogleAccess This property is required. bool
Whether the VMs in the subnet can access Google services without assigned external IP addresses.
SelfLink This property is required. string
The self link of the subnetwork.
Description This property is required. string
Description of the subnetwork.
IpCidrRange This property is required. string
The IP address range represented as a CIDR block.
Name This property is required. string
The name of the subnetwork.
Network This property is required. string
The self link of the parent network.
NetworkSelfLink This property is required. string
PrivateIpGoogleAccess This property is required. bool
Whether the VMs in the subnet can access Google services without assigned external IP addresses.
SelfLink This property is required. string
The self link of the subnetwork.
description This property is required. String
Description of the subnetwork.
ipCidrRange This property is required. String
The IP address range represented as a CIDR block.
name This property is required. String
The name of the subnetwork.
network This property is required. String
The self link of the parent network.
networkSelfLink This property is required. String
privateIpGoogleAccess This property is required. Boolean
Whether the VMs in the subnet can access Google services without assigned external IP addresses.
selfLink This property is required. String
The self link of the subnetwork.
description This property is required. string
Description of the subnetwork.
ipCidrRange This property is required. string
The IP address range represented as a CIDR block.
name This property is required. string
The name of the subnetwork.
network This property is required. string
The self link of the parent network.
networkSelfLink This property is required. string
privateIpGoogleAccess This property is required. boolean
Whether the VMs in the subnet can access Google services without assigned external IP addresses.
selfLink This property is required. string
The self link of the subnetwork.
description This property is required. str
Description of the subnetwork.
ip_cidr_range This property is required. str
The IP address range represented as a CIDR block.
name This property is required. str
The name of the subnetwork.
network This property is required. str
The self link of the parent network.
network_self_link This property is required. str
private_ip_google_access This property is required. bool
Whether the VMs in the subnet can access Google services without assigned external IP addresses.
self_link This property is required. str
The self link of the subnetwork.
description This property is required. String
Description of the subnetwork.
ipCidrRange This property is required. String
The IP address range represented as a CIDR block.
name This property is required. String
The name of the subnetwork.
network This property is required. String
The self link of the parent network.
networkSelfLink This property is required. String
privateIpGoogleAccess This property is required. Boolean
Whether the VMs in the subnet can access Google services without assigned external IP addresses.
selfLink This property is required. String
The self link of the subnetwork.

Package Details

Repository
Google Cloud (GCP) Classic pulumi/pulumi-gcp
License
Apache-2.0
Notes
This Pulumi package is based on the google-beta Terraform Provider.
Google Cloud v8.25.1 published on Wednesday, Apr 9, 2025 by Pulumi