1. Packages
  2. Linode Provider
  3. API Docs
  4. getVpcSubnets
Linode v4.36.0 published on Thursday, Mar 27, 2025 by Pulumi

linode.getVpcSubnets

Explore with Pulumi AI

Provides information about a list of Linode VPC subnets that match a set of filters. For more information, see the Linode APIv4 docs.

Example Usage

The following example shows how one might use this data source to list VPC subnets.

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

const filtered_subnets = linode.getVpcSubnets({
    vpcId: 123,
    filters: [{
        name: "label",
        values: ["test"],
    }],
});
export const vpcSubnets = filtered_subnets.then(filtered_subnets => filtered_subnets.vpcSubnets);
Copy
import pulumi
import pulumi_linode as linode

filtered_subnets = linode.get_vpc_subnets(vpc_id=123,
    filters=[{
        "name": "label",
        "values": ["test"],
    }])
pulumi.export("vpcSubnets", filtered_subnets.vpc_subnets)
Copy
package main

import (
	"github.com/pulumi/pulumi-linode/sdk/v4/go/linode"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		filtered_subnets, err := linode.GetVpcSubnets(ctx, &linode.GetVpcSubnetsArgs{
			VpcId: 123,
			Filters: []linode.GetVpcSubnetsFilter{
				{
					Name: "label",
					Values: []string{
						"test",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("vpcSubnets", filtered_subnets.VpcSubnets)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Linode = Pulumi.Linode;

return await Deployment.RunAsync(() => 
{
    var filtered_subnets = Linode.GetVpcSubnets.Invoke(new()
    {
        VpcId = 123,
        Filters = new[]
        {
            new Linode.Inputs.GetVpcSubnetsFilterInputArgs
            {
                Name = "label",
                Values = new[]
                {
                    "test",
                },
            },
        },
    });

    return new Dictionary<string, object?>
    {
        ["vpcSubnets"] = filtered_subnets.Apply(filtered_subnets => filtered_subnets.Apply(getVpcSubnetsResult => getVpcSubnetsResult.VpcSubnets)),
    };
});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.linode.LinodeFunctions;
import com.pulumi.linode.inputs.GetVpcSubnetsArgs;
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 filtered-subnets = LinodeFunctions.getVpcSubnets(GetVpcSubnetsArgs.builder()
            .vpcId(123)
            .filters(GetVpcSubnetsFilterArgs.builder()
                .name("label")
                .values("test")
                .build())
            .build());

        ctx.export("vpcSubnets", filtered_subnets.vpcSubnets());
    }
}
Copy
variables:
  filtered-subnets:
    fn::invoke:
      function: linode:getVpcSubnets
      arguments:
        vpcId: 123
        filters:
          - name: label
            values:
              - test
outputs:
  vpcSubnets: ${["filtered-subnets"].vpcSubnets}
Copy

Filterable Fields

  • id

  • label

  • ipv4

Using getVpcSubnets

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 getVpcSubnets(args: GetVpcSubnetsArgs, opts?: InvokeOptions): Promise<GetVpcSubnetsResult>
function getVpcSubnetsOutput(args: GetVpcSubnetsOutputArgs, opts?: InvokeOptions): Output<GetVpcSubnetsResult>
Copy
def get_vpc_subnets(filters: Optional[Sequence[GetVpcSubnetsFilter]] = None,
                    vpc_id: Optional[int] = None,
                    vpc_subnets: Optional[Sequence[GetVpcSubnetsVpcSubnet]] = None,
                    opts: Optional[InvokeOptions] = None) -> GetVpcSubnetsResult
def get_vpc_subnets_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetVpcSubnetsFilterArgs]]]] = None,
                    vpc_id: Optional[pulumi.Input[int]] = None,
                    vpc_subnets: Optional[pulumi.Input[Sequence[pulumi.Input[GetVpcSubnetsVpcSubnetArgs]]]] = None,
                    opts: Optional[InvokeOptions] = None) -> Output[GetVpcSubnetsResult]
Copy
func GetVpcSubnets(ctx *Context, args *GetVpcSubnetsArgs, opts ...InvokeOption) (*GetVpcSubnetsResult, error)
func GetVpcSubnetsOutput(ctx *Context, args *GetVpcSubnetsOutputArgs, opts ...InvokeOption) GetVpcSubnetsResultOutput
Copy

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

public static class GetVpcSubnets 
{
    public static Task<GetVpcSubnetsResult> InvokeAsync(GetVpcSubnetsArgs args, InvokeOptions? opts = null)
    public static Output<GetVpcSubnetsResult> Invoke(GetVpcSubnetsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetVpcSubnetsResult> getVpcSubnets(GetVpcSubnetsArgs args, InvokeOptions options)
public static Output<GetVpcSubnetsResult> getVpcSubnets(GetVpcSubnetsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: linode:index/getVpcSubnets:getVpcSubnets
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

VpcId This property is required. int
The id of the parent VPC for the list of VPCs.

  • filter - (Optional) A set of filters used to select Linode VPC subnets that meet certain requirements.
Filters List<GetVpcSubnetsFilter>
VpcSubnets List<GetVpcSubnetsVpcSubnet>
VpcId This property is required. int
The id of the parent VPC for the list of VPCs.

  • filter - (Optional) A set of filters used to select Linode VPC subnets that meet certain requirements.
Filters []GetVpcSubnetsFilter
VpcSubnets []GetVpcSubnetsVpcSubnet
vpcId This property is required. Integer
The id of the parent VPC for the list of VPCs.

  • filter - (Optional) A set of filters used to select Linode VPC subnets that meet certain requirements.
filters List<GetVpcSubnetsFilter>
vpcSubnets List<GetVpcSubnetsVpcSubnet>
vpcId This property is required. number
The id of the parent VPC for the list of VPCs.

  • filter - (Optional) A set of filters used to select Linode VPC subnets that meet certain requirements.
filters GetVpcSubnetsFilter[]
vpcSubnets GetVpcSubnetsVpcSubnet[]
vpc_id This property is required. int
The id of the parent VPC for the list of VPCs.

  • filter - (Optional) A set of filters used to select Linode VPC subnets that meet certain requirements.
filters Sequence[GetVpcSubnetsFilter]
vpc_subnets Sequence[GetVpcSubnetsVpcSubnet]
vpcId This property is required. Number
The id of the parent VPC for the list of VPCs.

  • filter - (Optional) A set of filters used to select Linode VPC subnets that meet certain requirements.
filters List<Property Map>
vpcSubnets List<Property Map>

getVpcSubnets Result

The following output properties are available:

id string
The unique id of the VPC subnet.
vpcId number
filters GetVpcSubnetsFilter[]
vpcSubnets GetVpcSubnetsVpcSubnet[]
id String
The unique id of the VPC subnet.
vpcId Number
filters List<Property Map>
vpcSubnets List<Property Map>

Supporting Types

GetVpcSubnetsFilter

Name This property is required. string
The name of the field to filter by. See the Filterable Fields section for a complete list of filterable fields.
Values This property is required. List<string>
A list of values for the filter to allow. These values should all be in string form.
MatchBy string
The method to match the field by. (exact, regex, substring; default exact)
Name This property is required. string
The name of the field to filter by. See the Filterable Fields section for a complete list of filterable fields.
Values This property is required. []string
A list of values for the filter to allow. These values should all be in string form.
MatchBy string
The method to match the field by. (exact, regex, substring; default exact)
name This property is required. String
The name of the field to filter by. See the Filterable Fields section for a complete list of filterable fields.
values This property is required. List<String>
A list of values for the filter to allow. These values should all be in string form.
matchBy String
The method to match the field by. (exact, regex, substring; default exact)
name This property is required. string
The name of the field to filter by. See the Filterable Fields section for a complete list of filterable fields.
values This property is required. string[]
A list of values for the filter to allow. These values should all be in string form.
matchBy string
The method to match the field by. (exact, regex, substring; default exact)
name This property is required. str
The name of the field to filter by. See the Filterable Fields section for a complete list of filterable fields.
values This property is required. Sequence[str]
A list of values for the filter to allow. These values should all be in string form.
match_by str
The method to match the field by. (exact, regex, substring; default exact)
name This property is required. String
The name of the field to filter by. See the Filterable Fields section for a complete list of filterable fields.
values This property is required. List<String>
A list of values for the filter to allow. These values should all be in string form.
matchBy String
The method to match the field by. (exact, regex, substring; default exact)

GetVpcSubnetsVpcSubnet

Created This property is required. string
The date and time when the VPC Subnet was created.
Id This property is required. int
The unique id of the VPC subnet.
Ipv4 This property is required. string
The IPv4 range of this subnet in CIDR format.
Label This property is required. string
The label of the VPC subnet.
Linodes This property is required. List<GetVpcSubnetsVpcSubnetLinode>
A list of Linode IDs that added to this subnet.
Updated This property is required. string
The date and time when the VPC Subnet was last updated.
Created This property is required. string
The date and time when the VPC Subnet was created.
Id This property is required. int
The unique id of the VPC subnet.
Ipv4 This property is required. string
The IPv4 range of this subnet in CIDR format.
Label This property is required. string
The label of the VPC subnet.
Linodes This property is required. []GetVpcSubnetsVpcSubnetLinode
A list of Linode IDs that added to this subnet.
Updated This property is required. string
The date and time when the VPC Subnet was last updated.
created This property is required. String
The date and time when the VPC Subnet was created.
id This property is required. Integer
The unique id of the VPC subnet.
ipv4 This property is required. String
The IPv4 range of this subnet in CIDR format.
label This property is required. String
The label of the VPC subnet.
linodes This property is required. List<GetVpcSubnetsVpcSubnetLinode>
A list of Linode IDs that added to this subnet.
updated This property is required. String
The date and time when the VPC Subnet was last updated.
created This property is required. string
The date and time when the VPC Subnet was created.
id This property is required. number
The unique id of the VPC subnet.
ipv4 This property is required. string
The IPv4 range of this subnet in CIDR format.
label This property is required. string
The label of the VPC subnet.
linodes This property is required. GetVpcSubnetsVpcSubnetLinode[]
A list of Linode IDs that added to this subnet.
updated This property is required. string
The date and time when the VPC Subnet was last updated.
created This property is required. str
The date and time when the VPC Subnet was created.
id This property is required. int
The unique id of the VPC subnet.
ipv4 This property is required. str
The IPv4 range of this subnet in CIDR format.
label This property is required. str
The label of the VPC subnet.
linodes This property is required. Sequence[GetVpcSubnetsVpcSubnetLinode]
A list of Linode IDs that added to this subnet.
updated This property is required. str
The date and time when the VPC Subnet was last updated.
created This property is required. String
The date and time when the VPC Subnet was created.
id This property is required. Number
The unique id of the VPC subnet.
ipv4 This property is required. String
The IPv4 range of this subnet in CIDR format.
label This property is required. String
The label of the VPC subnet.
linodes This property is required. List<Property Map>
A list of Linode IDs that added to this subnet.
updated This property is required. String
The date and time when the VPC Subnet was last updated.

GetVpcSubnetsVpcSubnetLinode

Id This property is required. int
The unique id of the VPC subnet.
Interfaces This property is required. List<GetVpcSubnetsVpcSubnetLinodeInterface>
Id This property is required. int
The unique id of the VPC subnet.
Interfaces This property is required. []GetVpcSubnetsVpcSubnetLinodeInterface
id This property is required. Integer
The unique id of the VPC subnet.
interfaces This property is required. List<GetVpcSubnetsVpcSubnetLinodeInterface>
id This property is required. number
The unique id of the VPC subnet.
interfaces This property is required. GetVpcSubnetsVpcSubnetLinodeInterface[]
id This property is required. int
The unique id of the VPC subnet.
interfaces This property is required. Sequence[GetVpcSubnetsVpcSubnetLinodeInterface]
id This property is required. Number
The unique id of the VPC subnet.
interfaces This property is required. List<Property Map>

GetVpcSubnetsVpcSubnetLinodeInterface

Active This property is required. bool
Id This property is required. int
The unique id of the VPC subnet.
Active This property is required. bool
Id This property is required. int
The unique id of the VPC subnet.
active This property is required. Boolean
id This property is required. Integer
The unique id of the VPC subnet.
active This property is required. boolean
id This property is required. number
The unique id of the VPC subnet.
active This property is required. bool
id This property is required. int
The unique id of the VPC subnet.
active This property is required. Boolean
id This property is required. Number
The unique id of the VPC subnet.

Package Details

Repository
Linode pulumi/pulumi-linode
License
Apache-2.0
Notes
This Pulumi package is based on the linode Terraform Provider.