1. Packages
  2. Packages
  3. Civo Provider
  4. API Docs
  5. getVpcSubnet
Viewing docs for civo 1.2.3
published on Thursday, Apr 9, 2026 by civo
civo logo
Viewing docs for civo 1.2.3
published on Thursday, Apr 9, 2026 by civo

    Retrieve information about a VPC subnet for use in other resources.

    This data source provides all of the subnet’s properties as configured on your Civo account.

    Subnets may be looked up by id or name, and require the network_id.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as civo from "@pulumi/civo";
    
    const example = civo.getVpcSubnet({
        name: "example-subnet",
        networkId: exampleCivoVpcNetwork.id,
    });
    
    import pulumi
    import pulumi_civo as civo
    
    example = civo.get_vpc_subnet(name="example-subnet",
        network_id=example_civo_vpc_network["id"])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/civo/civo"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := civo.LookupVpcSubnet(ctx, &civo.LookupVpcSubnetArgs{
    			Name:      pulumi.StringRef("example-subnet"),
    			NetworkId: exampleCivoVpcNetwork.Id,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Civo = Pulumi.Civo;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Civo.GetVpcSubnet.Invoke(new()
        {
            Name = "example-subnet",
            NetworkId = exampleCivoVpcNetwork.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.civo.CivoFunctions;
    import com.pulumi.civo.inputs.GetVpcSubnetArgs;
    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 example = CivoFunctions.getVpcSubnet(GetVpcSubnetArgs.builder()
                .name("example-subnet")
                .networkId(exampleCivoVpcNetwork.id())
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: civo:getVpcSubnet
          arguments:
            name: example-subnet
            networkId: ${exampleCivoVpcNetwork.id}
    

    Using getVpcSubnet

    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 getVpcSubnet(args: GetVpcSubnetArgs, opts?: InvokeOptions): Promise<GetVpcSubnetResult>
    function getVpcSubnetOutput(args: GetVpcSubnetOutputArgs, opts?: InvokeOptions): Output<GetVpcSubnetResult>
    def get_vpc_subnet(id: Optional[str] = None,
                       name: Optional[str] = None,
                       network_id: Optional[str] = None,
                       region: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetVpcSubnetResult
    def get_vpc_subnet_output(id: Optional[pulumi.Input[str]] = None,
                       name: Optional[pulumi.Input[str]] = None,
                       network_id: Optional[pulumi.Input[str]] = None,
                       region: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetVpcSubnetResult]
    func LookupVpcSubnet(ctx *Context, args *LookupVpcSubnetArgs, opts ...InvokeOption) (*LookupVpcSubnetResult, error)
    func LookupVpcSubnetOutput(ctx *Context, args *LookupVpcSubnetOutputArgs, opts ...InvokeOption) LookupVpcSubnetResultOutput

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

    public static class GetVpcSubnet 
    {
        public static Task<GetVpcSubnetResult> InvokeAsync(GetVpcSubnetArgs args, InvokeOptions? opts = null)
        public static Output<GetVpcSubnetResult> Invoke(GetVpcSubnetInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetVpcSubnetResult> getVpcSubnet(GetVpcSubnetArgs args, InvokeOptions options)
    public static Output<GetVpcSubnetResult> getVpcSubnet(GetVpcSubnetArgs args, InvokeOptions options)
    
    fn::invoke:
      function: civo:index/getVpcSubnet:getVpcSubnet
      arguments:
        # arguments dictionary

    The following arguments are supported:

    NetworkId string
    The ID of the VPC network this subnet belongs to
    Id string
    The ID of the VPC subnet
    Name string
    The name of the VPC subnet
    Region string
    The region of the subnet
    NetworkId string
    The ID of the VPC network this subnet belongs to
    Id string
    The ID of the VPC subnet
    Name string
    The name of the VPC subnet
    Region string
    The region of the subnet
    networkId String
    The ID of the VPC network this subnet belongs to
    id String
    The ID of the VPC subnet
    name String
    The name of the VPC subnet
    region String
    The region of the subnet
    networkId string
    The ID of the VPC network this subnet belongs to
    id string
    The ID of the VPC subnet
    name string
    The name of the VPC subnet
    region string
    The region of the subnet
    network_id str
    The ID of the VPC network this subnet belongs to
    id str
    The ID of the VPC subnet
    name str
    The name of the VPC subnet
    region str
    The region of the subnet
    networkId String
    The ID of the VPC network this subnet belongs to
    id String
    The ID of the VPC subnet
    name String
    The name of the VPC subnet
    region String
    The region of the subnet

    getVpcSubnet Result

    The following output properties are available:

    NetworkId string
    The ID of the VPC network this subnet belongs to
    Status string
    The status of the subnet
    SubnetSize string
    The size of the subnet
    Id string
    The ID of the VPC subnet
    Name string
    The name of the VPC subnet
    Region string
    The region of the subnet
    NetworkId string
    The ID of the VPC network this subnet belongs to
    Status string
    The status of the subnet
    SubnetSize string
    The size of the subnet
    Id string
    The ID of the VPC subnet
    Name string
    The name of the VPC subnet
    Region string
    The region of the subnet
    networkId String
    The ID of the VPC network this subnet belongs to
    status String
    The status of the subnet
    subnetSize String
    The size of the subnet
    id String
    The ID of the VPC subnet
    name String
    The name of the VPC subnet
    region String
    The region of the subnet
    networkId string
    The ID of the VPC network this subnet belongs to
    status string
    The status of the subnet
    subnetSize string
    The size of the subnet
    id string
    The ID of the VPC subnet
    name string
    The name of the VPC subnet
    region string
    The region of the subnet
    network_id str
    The ID of the VPC network this subnet belongs to
    status str
    The status of the subnet
    subnet_size str
    The size of the subnet
    id str
    The ID of the VPC subnet
    name str
    The name of the VPC subnet
    region str
    The region of the subnet
    networkId String
    The ID of the VPC network this subnet belongs to
    status String
    The status of the subnet
    subnetSize String
    The size of the subnet
    id String
    The ID of the VPC subnet
    name String
    The name of the VPC subnet
    region String
    The region of the subnet

    Package Details

    Repository
    Civo civo/terraform-provider-civo
    License
    Notes
    This Pulumi package is based on the civo Terraform Provider.
    civo logo
    Viewing docs for civo 1.2.3
    published on Thursday, Apr 9, 2026 by civo
      Try Pulumi Cloud free. Your team will thank you.