Google Cloud v8.27.0 published on Thursday, Apr 17, 2025 by Pulumi
gcp.compute.getSubnetworks
Explore with Pulumi AI
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",
});
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")
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
	})
}
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",
    });
});
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());
    }
}
variables:
  my-subnetworks:
    fn::invoke:
      function: gcp:compute:getSubnetworks
      arguments:
        filter: ipCidrRange eq 192.168.178.0/24
        project: my-project
        region: us-east1
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>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]func GetSubnetworks(ctx *Context, args *GetSubnetworksArgs, opts ...InvokeOption) (*GetSubnetworksResult, error)
func GetSubnetworksOutput(ctx *Context, args *GetSubnetworksOutputArgs, opts ...InvokeOption) GetSubnetworksResultOutput> 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)
}public static CompletableFuture<GetSubnetworksResult> getSubnetworks(GetSubnetworksArgs args, InvokeOptions options)
public static Output<GetSubnetworksResult> getSubnetworks(GetSubnetworksArgs args, InvokeOptions options)
fn::invoke:
  function: gcp:compute/getSubnetworks:getSubnetworks
  arguments:
    # arguments dictionaryThe 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 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<Get
Subnetworks Subnetwork>  - 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
[]Get
Subnetworks Subnetwork  - 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<Get
Subnetworks Subnetwork>  - 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
Get
Subnetworks Subnetwork[]  - 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[Get
Subnetworks Subnetwork]  - 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 string
 - Description of the subnetwork.
 - Ip
Cidr stringRange  - The IP address range represented as a CIDR block.
 - Name string
 - The name of the subnetwork.
 - Network string
 - The self link of the parent network.
 - Network
Self stringLink  - Private
Ip boolGoogle Access  - Whether the VMs in the subnet can access Google services without assigned external IP addresses.
 - Self
Link string - The self link of the subnetwork.
 
- Description string
 - Description of the subnetwork.
 - Ip
Cidr stringRange  - The IP address range represented as a CIDR block.
 - Name string
 - The name of the subnetwork.
 - Network string
 - The self link of the parent network.
 - Network
Self stringLink  - Private
Ip boolGoogle Access  - Whether the VMs in the subnet can access Google services without assigned external IP addresses.
 - Self
Link string - The self link of the subnetwork.
 
- description String
 - Description of the subnetwork.
 - ip
Cidr StringRange  - The IP address range represented as a CIDR block.
 - name String
 - The name of the subnetwork.
 - network String
 - The self link of the parent network.
 - network
Self StringLink  - private
Ip BooleanGoogle Access  - Whether the VMs in the subnet can access Google services without assigned external IP addresses.
 - self
Link String - The self link of the subnetwork.
 
- description string
 - Description of the subnetwork.
 - ip
Cidr stringRange  - The IP address range represented as a CIDR block.
 - name string
 - The name of the subnetwork.
 - network string
 - The self link of the parent network.
 - network
Self stringLink  - private
Ip booleanGoogle Access  - Whether the VMs in the subnet can access Google services without assigned external IP addresses.
 - self
Link string - The self link of the subnetwork.
 
- description str
 - Description of the subnetwork.
 - ip_
cidr_ strrange  - The IP address range represented as a CIDR block.
 - name str
 - The name of the subnetwork.
 - network str
 - The self link of the parent network.
 - network_
self_ strlink  - private_
ip_ boolgoogle_ access  - Whether the VMs in the subnet can access Google services without assigned external IP addresses.
 - self_
link str - The self link of the subnetwork.
 
- description String
 - Description of the subnetwork.
 - ip
Cidr StringRange  - The IP address range represented as a CIDR block.
 - name String
 - The name of the subnetwork.
 - network String
 - The self link of the parent network.
 - network
Self StringLink  - private
Ip BooleanGoogle Access  - Whether the VMs in the subnet can access Google services without assigned external IP addresses.
 - self
Link 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-betaTerraform Provider.