Google Cloud v8.22.0 published on Thursday, Mar 13, 2025 by Pulumi
gcp.compute.getSubnetwork
Explore with Pulumi AI
Get a subnetwork within GCE from its name and region.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const my_subnetwork = gcp.compute.getSubnetwork({
    name: "default-us-east1",
    region: "us-east1",
});
import pulumi
import pulumi_gcp as gcp
my_subnetwork = gcp.compute.get_subnetwork(name="default-us-east1",
    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.LookupSubnetwork(ctx, &compute.LookupSubnetworkArgs{
			Name:   pulumi.StringRef("default-us-east1"),
			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_subnetwork = Gcp.Compute.GetSubnetwork.Invoke(new()
    {
        Name = "default-us-east1",
        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.GetSubnetworkArgs;
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-subnetwork = ComputeFunctions.getSubnetwork(GetSubnetworkArgs.builder()
            .name("default-us-east1")
            .region("us-east1")
            .build());
    }
}
variables:
  my-subnetwork:
    fn::invoke:
      function: gcp:compute:getSubnetwork
      arguments:
        name: default-us-east1
        region: us-east1
Using getSubnetwork
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 getSubnetwork(args: GetSubnetworkArgs, opts?: InvokeOptions): Promise<GetSubnetworkResult>
function getSubnetworkOutput(args: GetSubnetworkOutputArgs, opts?: InvokeOptions): Output<GetSubnetworkResult>def get_subnetwork(name: Optional[str] = None,
                   project: Optional[str] = None,
                   region: Optional[str] = None,
                   self_link: Optional[str] = None,
                   opts: Optional[InvokeOptions] = None) -> GetSubnetworkResult
def get_subnetwork_output(name: Optional[pulumi.Input[str]] = None,
                   project: Optional[pulumi.Input[str]] = None,
                   region: Optional[pulumi.Input[str]] = None,
                   self_link: Optional[pulumi.Input[str]] = None,
                   opts: Optional[InvokeOptions] = None) -> Output[GetSubnetworkResult]func LookupSubnetwork(ctx *Context, args *LookupSubnetworkArgs, opts ...InvokeOption) (*LookupSubnetworkResult, error)
func LookupSubnetworkOutput(ctx *Context, args *LookupSubnetworkOutputArgs, opts ...InvokeOption) LookupSubnetworkResultOutput> Note: This function is named LookupSubnetwork in the Go SDK.
public static class GetSubnetwork 
{
    public static Task<GetSubnetworkResult> InvokeAsync(GetSubnetworkArgs args, InvokeOptions? opts = null)
    public static Output<GetSubnetworkResult> Invoke(GetSubnetworkInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetSubnetworkResult> getSubnetwork(GetSubnetworkArgs args, InvokeOptions options)
public static Output<GetSubnetworkResult> getSubnetwork(GetSubnetworkArgs args, InvokeOptions options)
fn::invoke:
  function: gcp:compute/getSubnetwork:getSubnetwork
  arguments:
    # arguments dictionaryThe following arguments are supported:
- Name string
- The name of the subnetwork. One of nameorself_linkmust be specified.
- 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.
- SelfLink string
- The self link of the subnetwork. If self_linkis specified,name,project, andregionare ignored.
- Name string
- The name of the subnetwork. One of nameorself_linkmust be specified.
- 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.
- SelfLink string
- The self link of the subnetwork. If self_linkis specified,name,project, andregionare ignored.
- name String
- The name of the subnetwork. One of nameorself_linkmust be specified.
- 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.
- selfLink String
- The self link of the subnetwork. If self_linkis specified,name,project, andregionare ignored.
- name string
- The name of the subnetwork. One of nameorself_linkmust be specified.
- 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.
- selfLink string
- The self link of the subnetwork. If self_linkis specified,name,project, andregionare ignored.
- name str
- The name of the subnetwork. One of nameorself_linkmust be specified.
- 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.
- self_link str
- The self link of the subnetwork. If self_linkis specified,name,project, andregionare ignored.
- name String
- The name of the subnetwork. One of nameorself_linkmust be specified.
- 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.
- selfLink String
- The self link of the subnetwork. If self_linkis specified,name,project, andregionare ignored.
getSubnetwork Result
The following output properties are available:
- Description string
- Description of this subnetwork.
- GatewayAddress string
- The IP address of the gateway.
- Id string
- The provider-assigned unique ID for this managed resource.
- InternalIpv6Prefix string
- The internal IPv6 address range that is assigned to this subnetwork.
- IpCidr stringRange 
- The range of IP addresses belonging to this subnetwork secondary range.
- Network string
- The network name or resource link to the parent network of this subnetwork.
- PrivateIp boolGoogle Access 
- Whether the VMs in this subnet can access Google services without assigned external IP addresses.
- Project string
- Region string
- SecondaryIp List<GetRanges Subnetwork Secondary Ip Range> 
- An array of configurations for secondary IP ranges for VM instances contained in this subnetwork. Structure is documented below.
- SelfLink string
- SubnetworkId int
- The numeric ID of the resource.
- Name string
- Description string
- Description of this subnetwork.
- GatewayAddress string
- The IP address of the gateway.
- Id string
- The provider-assigned unique ID for this managed resource.
- InternalIpv6Prefix string
- The internal IPv6 address range that is assigned to this subnetwork.
- IpCidr stringRange 
- The range of IP addresses belonging to this subnetwork secondary range.
- Network string
- The network name or resource link to the parent network of this subnetwork.
- PrivateIp boolGoogle Access 
- Whether the VMs in this subnet can access Google services without assigned external IP addresses.
- Project string
- Region string
- SecondaryIp []GetRanges Subnetwork Secondary Ip Range 
- An array of configurations for secondary IP ranges for VM instances contained in this subnetwork. Structure is documented below.
- SelfLink string
- SubnetworkId int
- The numeric ID of the resource.
- Name string
- description String
- Description of this subnetwork.
- gatewayAddress String
- The IP address of the gateway.
- id String
- The provider-assigned unique ID for this managed resource.
- internalIpv6Prefix String
- The internal IPv6 address range that is assigned to this subnetwork.
- ipCidr StringRange 
- The range of IP addresses belonging to this subnetwork secondary range.
- network String
- The network name or resource link to the parent network of this subnetwork.
- privateIp BooleanGoogle Access 
- Whether the VMs in this subnet can access Google services without assigned external IP addresses.
- project String
- region String
- secondaryIp List<GetRanges Subnetwork Secondary Ip Range> 
- An array of configurations for secondary IP ranges for VM instances contained in this subnetwork. Structure is documented below.
- selfLink String
- subnetworkId Integer
- The numeric ID of the resource.
- name String
- description string
- Description of this subnetwork.
- gatewayAddress string
- The IP address of the gateway.
- id string
- The provider-assigned unique ID for this managed resource.
- internalIpv6Prefix string
- The internal IPv6 address range that is assigned to this subnetwork.
- ipCidr stringRange 
- The range of IP addresses belonging to this subnetwork secondary range.
- network string
- The network name or resource link to the parent network of this subnetwork.
- privateIp booleanGoogle Access 
- Whether the VMs in this subnet can access Google services without assigned external IP addresses.
- project string
- region string
- secondaryIp GetRanges Subnetwork Secondary Ip Range[] 
- An array of configurations for secondary IP ranges for VM instances contained in this subnetwork. Structure is documented below.
- selfLink string
- subnetworkId number
- The numeric ID of the resource.
- name string
- description str
- Description of this subnetwork.
- gateway_address str
- The IP address of the gateway.
- id str
- The provider-assigned unique ID for this managed resource.
- internal_ipv6_ strprefix 
- The internal IPv6 address range that is assigned to this subnetwork.
- ip_cidr_ strrange 
- The range of IP addresses belonging to this subnetwork secondary range.
- network str
- The network name or resource link to the parent network of this subnetwork.
- private_ip_ boolgoogle_ access 
- Whether the VMs in this subnet can access Google services without assigned external IP addresses.
- project str
- region str
- secondary_ip_ Sequence[Getranges Subnetwork Secondary Ip Range] 
- An array of configurations for secondary IP ranges for VM instances contained in this subnetwork. Structure is documented below.
- self_link str
- subnetwork_id int
- The numeric ID of the resource.
- name str
- description String
- Description of this subnetwork.
- gatewayAddress String
- The IP address of the gateway.
- id String
- The provider-assigned unique ID for this managed resource.
- internalIpv6Prefix String
- The internal IPv6 address range that is assigned to this subnetwork.
- ipCidr StringRange 
- The range of IP addresses belonging to this subnetwork secondary range.
- network String
- The network name or resource link to the parent network of this subnetwork.
- privateIp BooleanGoogle Access 
- Whether the VMs in this subnet can access Google services without assigned external IP addresses.
- project String
- region String
- secondaryIp List<Property Map>Ranges 
- An array of configurations for secondary IP ranges for VM instances contained in this subnetwork. Structure is documented below.
- selfLink String
- subnetworkId Number
- The numeric ID of the resource.
- name String
Supporting Types
GetSubnetworkSecondaryIpRange    
- IpCidr stringRange 
- The range of IP addresses belonging to this subnetwork secondary range.
- RangeName string
- The name associated with this subnetwork secondary range, used when adding an alias IP range to a VM instance.
- IpCidr stringRange 
- The range of IP addresses belonging to this subnetwork secondary range.
- RangeName string
- The name associated with this subnetwork secondary range, used when adding an alias IP range to a VM instance.
- ipCidr StringRange 
- The range of IP addresses belonging to this subnetwork secondary range.
- rangeName String
- The name associated with this subnetwork secondary range, used when adding an alias IP range to a VM instance.
- ipCidr stringRange 
- The range of IP addresses belonging to this subnetwork secondary range.
- rangeName string
- The name associated with this subnetwork secondary range, used when adding an alias IP range to a VM instance.
- ip_cidr_ strrange 
- The range of IP addresses belonging to this subnetwork secondary range.
- range_name str
- The name associated with this subnetwork secondary range, used when adding an alias IP range to a VM instance.
- ipCidr StringRange 
- The range of IP addresses belonging to this subnetwork secondary range.
- rangeName String
- The name associated with this subnetwork secondary range, used when adding an alias IP range to a VM instance.
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.