Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 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/v7/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)
// Output-based functions aren't available in Java yet
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.
 - Self
Link 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.
 - Self
Link 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.
 - self
Link 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.
 - self
Link 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.
 - self
Link 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.
 - Gateway
Address string - The IP address of the gateway.
 - Id string
 - The provider-assigned unique ID for this managed resource.
 - Internal
Ipv6Prefix string - The internal IPv6 address range that is assigned to this subnetwork.
 - Ip
Cidr 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.
 - Private
Ip boolGoogle Access  - Whether the VMs in this subnet can access Google services without assigned external IP addresses.
 - Project string
 - Region string
 - Secondary
Ip 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.
 - Self
Link string - Name string
 
- Description string
 - Description of this subnetwork.
 - Gateway
Address string - The IP address of the gateway.
 - Id string
 - The provider-assigned unique ID for this managed resource.
 - Internal
Ipv6Prefix string - The internal IPv6 address range that is assigned to this subnetwork.
 - Ip
Cidr 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.
 - Private
Ip boolGoogle Access  - Whether the VMs in this subnet can access Google services without assigned external IP addresses.
 - Project string
 - Region string
 - Secondary
Ip []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 string - Name string
 
- description String
 - Description of this subnetwork.
 - gateway
Address String - The IP address of the gateway.
 - id String
 - The provider-assigned unique ID for this managed resource.
 - internal
Ipv6Prefix String - The internal IPv6 address range that is assigned to this subnetwork.
 - ip
Cidr 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.
 - private
Ip BooleanGoogle Access  - Whether the VMs in this subnet can access Google services without assigned external IP addresses.
 - project String
 - region String
 - secondary
Ip 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.
 - self
Link String - name String
 
- description string
 - Description of this subnetwork.
 - gateway
Address string - The IP address of the gateway.
 - id string
 - The provider-assigned unique ID for this managed resource.
 - internal
Ipv6Prefix string - The internal IPv6 address range that is assigned to this subnetwork.
 - ip
Cidr 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.
 - private
Ip booleanGoogle Access  - Whether the VMs in this subnet can access Google services without assigned external IP addresses.
 - project string
 - region string
 - secondary
Ip 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 string - 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 - name str
 
- description String
 - Description of this subnetwork.
 - gateway
Address String - The IP address of the gateway.
 - id String
 - The provider-assigned unique ID for this managed resource.
 - internal
Ipv6Prefix String - The internal IPv6 address range that is assigned to this subnetwork.
 - ip
Cidr 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.
 - private
Ip BooleanGoogle Access  - Whether the VMs in this subnet can access Google services without assigned external IP addresses.
 - project String
 - region String
 - secondary
Ip List<Property Map>Ranges  - An array of configurations for secondary IP ranges for VM instances contained in this subnetwork. Structure is documented below.
 - self
Link String - name String
 
Supporting Types
GetSubnetworkSecondaryIpRange    
- Ip
Cidr stringRange  - The range of IP addresses belonging to this subnetwork secondary range.
 - Range
Name string - The name associated with this subnetwork secondary range, used when adding an alias IP range to a VM instance.
 
- Ip
Cidr stringRange  - The range of IP addresses belonging to this subnetwork secondary range.
 - Range
Name string - The name associated with this subnetwork secondary range, used when adding an alias IP range to a VM instance.
 
- ip
Cidr StringRange  - The range of IP addresses belonging to this subnetwork secondary range.
 - range
Name String - The name associated with this subnetwork secondary range, used when adding an alias IP range to a VM instance.
 
- ip
Cidr stringRange  - The range of IP addresses belonging to this subnetwork secondary range.
 - range
Name 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.
 
- ip
Cidr StringRange  - The range of IP addresses belonging to this subnetwork secondary range.
 - range
Name 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.