1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. compute
  5. getNetwork
Google Cloud v8.23.0 published on Monday, Mar 24, 2025 by Pulumi

gcp.compute.getNetwork

Explore with Pulumi AI

Google Cloud v8.23.0 published on Monday, Mar 24, 2025 by Pulumi

Get a network within GCE from its name.

Example Usage

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

const my_network = gcp.compute.getNetwork({
    name: "default-us-east1",
});
Copy
import pulumi
import pulumi_gcp as gcp

my_network = gcp.compute.get_network(name="default-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.LookupNetwork(ctx, &compute.LookupNetworkArgs{
			Name: "default-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_network = Gcp.Compute.GetNetwork.Invoke(new()
    {
        Name = "default-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.GetNetworkArgs;
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-network = ComputeFunctions.getNetwork(GetNetworkArgs.builder()
            .name("default-us-east1")
            .build());

    }
}
Copy
variables:
  my-network:
    fn::invoke:
      function: gcp:compute:getNetwork
      arguments:
        name: default-us-east1
Copy

Using getNetwork

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 getNetwork(args: GetNetworkArgs, opts?: InvokeOptions): Promise<GetNetworkResult>
function getNetworkOutput(args: GetNetworkOutputArgs, opts?: InvokeOptions): Output<GetNetworkResult>
Copy
def get_network(name: Optional[str] = None,
                network_profile: Optional[str] = None,
                project: Optional[str] = None,
                opts: Optional[InvokeOptions] = None) -> GetNetworkResult
def get_network_output(name: Optional[pulumi.Input[str]] = None,
                network_profile: Optional[pulumi.Input[str]] = None,
                project: Optional[pulumi.Input[str]] = None,
                opts: Optional[InvokeOptions] = None) -> Output[GetNetworkResult]
Copy
func LookupNetwork(ctx *Context, args *LookupNetworkArgs, opts ...InvokeOption) (*LookupNetworkResult, error)
func LookupNetworkOutput(ctx *Context, args *LookupNetworkOutputArgs, opts ...InvokeOption) LookupNetworkResultOutput
Copy

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

public static class GetNetwork 
{
    public static Task<GetNetworkResult> InvokeAsync(GetNetworkArgs args, InvokeOptions? opts = null)
    public static Output<GetNetworkResult> Invoke(GetNetworkInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetNetworkResult> getNetwork(GetNetworkArgs args, InvokeOptions options)
public static Output<GetNetworkResult> getNetwork(GetNetworkArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: gcp:compute/getNetwork:getNetwork
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Name This property is required. string
The name of the network.


NetworkProfile string
A full or partial URL of the network profile to apply to this network.
Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Name This property is required. string
The name of the network.


NetworkProfile string
A full or partial URL of the network profile to apply to this network.
Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
name This property is required. String
The name of the network.


networkProfile String
A full or partial URL of the network profile to apply to this network.
project String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
name This property is required. string
The name of the network.


networkProfile string
A full or partial URL of the network profile to apply to this network.
project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
name This property is required. str
The name of the network.


network_profile str
A full or partial URL of the network profile to apply to this network.
project str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
name This property is required. String
The name of the network.


networkProfile String
A full or partial URL of the network profile to apply to this network.
project String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

getNetwork Result

The following output properties are available:

Description string
Description of this network.
GatewayIpv4 string
The IP address of the gateway.
Id string
The provider-assigned unique ID for this managed resource.
InternalIpv6Range string
The ula internal ipv6 range assigned to this network.
Name string
NetworkId int
The numeric unique identifier for the resource.
NumericId string
(Deprecated) The numeric unique identifier for the resource. numeric_id is deprecated and will be removed in a future major release. Use network_id instead.

Deprecated: numeric_id is deprecated and will be removed in a future major release. Use network_id instead.

SelfLink string
The URI of the resource.
SubnetworksSelfLinks List<string>
the list of subnetworks which belong to the network
NetworkProfile string
A full or partial URL of the network profile to apply to this network.
Project string
Description string
Description of this network.
GatewayIpv4 string
The IP address of the gateway.
Id string
The provider-assigned unique ID for this managed resource.
InternalIpv6Range string
The ula internal ipv6 range assigned to this network.
Name string
NetworkId int
The numeric unique identifier for the resource.
NumericId string
(Deprecated) The numeric unique identifier for the resource. numeric_id is deprecated and will be removed in a future major release. Use network_id instead.

Deprecated: numeric_id is deprecated and will be removed in a future major release. Use network_id instead.

SelfLink string
The URI of the resource.
SubnetworksSelfLinks []string
the list of subnetworks which belong to the network
NetworkProfile string
A full or partial URL of the network profile to apply to this network.
Project string
description String
Description of this network.
gatewayIpv4 String
The IP address of the gateway.
id String
The provider-assigned unique ID for this managed resource.
internalIpv6Range String
The ula internal ipv6 range assigned to this network.
name String
networkId Integer
The numeric unique identifier for the resource.
numericId String
(Deprecated) The numeric unique identifier for the resource. numeric_id is deprecated and will be removed in a future major release. Use network_id instead.

Deprecated: numeric_id is deprecated and will be removed in a future major release. Use network_id instead.

selfLink String
The URI of the resource.
subnetworksSelfLinks List<String>
the list of subnetworks which belong to the network
networkProfile String
A full or partial URL of the network profile to apply to this network.
project String
description string
Description of this network.
gatewayIpv4 string
The IP address of the gateway.
id string
The provider-assigned unique ID for this managed resource.
internalIpv6Range string
The ula internal ipv6 range assigned to this network.
name string
networkId number
The numeric unique identifier for the resource.
numericId string
(Deprecated) The numeric unique identifier for the resource. numeric_id is deprecated and will be removed in a future major release. Use network_id instead.

Deprecated: numeric_id is deprecated and will be removed in a future major release. Use network_id instead.

selfLink string
The URI of the resource.
subnetworksSelfLinks string[]
the list of subnetworks which belong to the network
networkProfile string
A full or partial URL of the network profile to apply to this network.
project string
description str
Description of this network.
gateway_ipv4 str
The IP address of the gateway.
id str
The provider-assigned unique ID for this managed resource.
internal_ipv6_range str
The ula internal ipv6 range assigned to this network.
name str
network_id int
The numeric unique identifier for the resource.
numeric_id str
(Deprecated) The numeric unique identifier for the resource. numeric_id is deprecated and will be removed in a future major release. Use network_id instead.

Deprecated: numeric_id is deprecated and will be removed in a future major release. Use network_id instead.

self_link str
The URI of the resource.
subnetworks_self_links Sequence[str]
the list of subnetworks which belong to the network
network_profile str
A full or partial URL of the network profile to apply to this network.
project str
description String
Description of this network.
gatewayIpv4 String
The IP address of the gateway.
id String
The provider-assigned unique ID for this managed resource.
internalIpv6Range String
The ula internal ipv6 range assigned to this network.
name String
networkId Number
The numeric unique identifier for the resource.
numericId String
(Deprecated) The numeric unique identifier for the resource. numeric_id is deprecated and will be removed in a future major release. Use network_id instead.

Deprecated: numeric_id is deprecated and will be removed in a future major release. Use network_id instead.

selfLink String
The URI of the resource.
subnetworksSelfLinks List<String>
the list of subnetworks which belong to the network
networkProfile String
A full or partial URL of the network profile to apply to this network.
project String

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.23.0 published on Monday, Mar 24, 2025 by Pulumi