1. Packages
  2. Openstack Provider
  3. API Docs
  4. networking
  5. getSubnet
OpenStack v5.0.3 published on Wednesday, Feb 12, 2025 by Pulumi

openstack.networking.getSubnet

Explore with Pulumi AI

OpenStack v5.0.3 published on Wednesday, Feb 12, 2025 by Pulumi

Use this data source to get the ID of an available OpenStack subnet.

Example Usage

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

const subnet1 = openstack.networking.getSubnet({
    name: "subnet_1",
});
Copy
import pulumi
import pulumi_openstack as openstack

subnet1 = openstack.networking.get_subnet(name="subnet_1")
Copy
package main

import (
	"github.com/pulumi/pulumi-openstack/sdk/v5/go/openstack/networking"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := networking.LookupSubnet(ctx, &networking.LookupSubnetArgs{
			Name: pulumi.StringRef("subnet_1"),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using OpenStack = Pulumi.OpenStack;

return await Deployment.RunAsync(() => 
{
    var subnet1 = OpenStack.Networking.GetSubnet.Invoke(new()
    {
        Name = "subnet_1",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.openstack.networking.NetworkingFunctions;
import com.pulumi.openstack.networking.inputs.GetSubnetArgs;
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 subnet1 = NetworkingFunctions.getSubnet(GetSubnetArgs.builder()
            .name("subnet_1")
            .build());

    }
}
Copy
variables:
  subnet1:
    fn::invoke:
      function: openstack:networking:getSubnet
      arguments:
        name: subnet_1
Copy

Using getSubnet

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 getSubnet(args: GetSubnetArgs, opts?: InvokeOptions): Promise<GetSubnetResult>
function getSubnetOutput(args: GetSubnetOutputArgs, opts?: InvokeOptions): Output<GetSubnetResult>
Copy
def get_subnet(cidr: Optional[str] = None,
               description: Optional[str] = None,
               dhcp_enabled: Optional[bool] = None,
               dns_publish_fixed_ip: Optional[bool] = None,
               gateway_ip: Optional[str] = None,
               ip_version: Optional[int] = None,
               ipv6_address_mode: Optional[str] = None,
               ipv6_ra_mode: Optional[str] = None,
               name: Optional[str] = None,
               network_id: Optional[str] = None,
               region: Optional[str] = None,
               subnet_id: Optional[str] = None,
               subnetpool_id: Optional[str] = None,
               tags: Optional[Sequence[str]] = None,
               tenant_id: Optional[str] = None,
               opts: Optional[InvokeOptions] = None) -> GetSubnetResult
def get_subnet_output(cidr: Optional[pulumi.Input[str]] = None,
               description: Optional[pulumi.Input[str]] = None,
               dhcp_enabled: Optional[pulumi.Input[bool]] = None,
               dns_publish_fixed_ip: Optional[pulumi.Input[bool]] = None,
               gateway_ip: Optional[pulumi.Input[str]] = None,
               ip_version: Optional[pulumi.Input[int]] = None,
               ipv6_address_mode: Optional[pulumi.Input[str]] = None,
               ipv6_ra_mode: Optional[pulumi.Input[str]] = None,
               name: Optional[pulumi.Input[str]] = None,
               network_id: Optional[pulumi.Input[str]] = None,
               region: Optional[pulumi.Input[str]] = None,
               subnet_id: Optional[pulumi.Input[str]] = None,
               subnetpool_id: Optional[pulumi.Input[str]] = None,
               tags: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
               tenant_id: Optional[pulumi.Input[str]] = None,
               opts: Optional[InvokeOptions] = None) -> Output[GetSubnetResult]
Copy
func LookupSubnet(ctx *Context, args *LookupSubnetArgs, opts ...InvokeOption) (*LookupSubnetResult, error)
func LookupSubnetOutput(ctx *Context, args *LookupSubnetOutputArgs, opts ...InvokeOption) LookupSubnetResultOutput
Copy

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

public static class GetSubnet 
{
    public static Task<GetSubnetResult> InvokeAsync(GetSubnetArgs args, InvokeOptions? opts = null)
    public static Output<GetSubnetResult> Invoke(GetSubnetInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetSubnetResult> getSubnet(GetSubnetArgs args, InvokeOptions options)
public static Output<GetSubnetResult> getSubnet(GetSubnetArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: openstack:networking/getSubnet:getSubnet
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Cidr string
The CIDR of the subnet.
Description string
Human-readable description of the subnet.
DhcpEnabled bool
If the subnet has DHCP enabled.
DnsPublishFixedIp bool
If the subnet publishes DNS records.
GatewayIp string
The IP of the subnet's gateway.
IpVersion int
The IP version of the subnet (either 4 or 6).
Ipv6AddressMode Changes to this property will trigger replacement. string
The IPv6 address mode. Valid values are dhcpv6-stateful, dhcpv6-stateless, or slaac.
Ipv6RaMode Changes to this property will trigger replacement. string
The IPv6 Router Advertisement mode. Valid values are dhcpv6-stateful, dhcpv6-stateless, or slaac.
Name string
The name of the subnet.
NetworkId string
The ID of the network the subnet belongs to.
Region Changes to this property will trigger replacement. string
The region in which to obtain the V2 Neutron client. A Neutron client is needed to retrieve subnet ids. If omitted, the region argument of the provider is used.
SubnetId string
The ID of the subnet.
SubnetpoolId string
The ID of the subnetpool associated with the subnet.
Tags List<string>
The list of subnet tags to filter.
TenantId string
The owner of the subnet.
Cidr string
The CIDR of the subnet.
Description string
Human-readable description of the subnet.
DhcpEnabled bool
If the subnet has DHCP enabled.
DnsPublishFixedIp bool
If the subnet publishes DNS records.
GatewayIp string
The IP of the subnet's gateway.
IpVersion int
The IP version of the subnet (either 4 or 6).
Ipv6AddressMode Changes to this property will trigger replacement. string
The IPv6 address mode. Valid values are dhcpv6-stateful, dhcpv6-stateless, or slaac.
Ipv6RaMode Changes to this property will trigger replacement. string
The IPv6 Router Advertisement mode. Valid values are dhcpv6-stateful, dhcpv6-stateless, or slaac.
Name string
The name of the subnet.
NetworkId string
The ID of the network the subnet belongs to.
Region Changes to this property will trigger replacement. string
The region in which to obtain the V2 Neutron client. A Neutron client is needed to retrieve subnet ids. If omitted, the region argument of the provider is used.
SubnetId string
The ID of the subnet.
SubnetpoolId string
The ID of the subnetpool associated with the subnet.
Tags []string
The list of subnet tags to filter.
TenantId string
The owner of the subnet.
cidr String
The CIDR of the subnet.
description String
Human-readable description of the subnet.
dhcpEnabled Boolean
If the subnet has DHCP enabled.
dnsPublishFixedIp Boolean
If the subnet publishes DNS records.
gatewayIp String
The IP of the subnet's gateway.
ipVersion Integer
The IP version of the subnet (either 4 or 6).
ipv6AddressMode Changes to this property will trigger replacement. String
The IPv6 address mode. Valid values are dhcpv6-stateful, dhcpv6-stateless, or slaac.
ipv6RaMode Changes to this property will trigger replacement. String
The IPv6 Router Advertisement mode. Valid values are dhcpv6-stateful, dhcpv6-stateless, or slaac.
name String
The name of the subnet.
networkId String
The ID of the network the subnet belongs to.
region Changes to this property will trigger replacement. String
The region in which to obtain the V2 Neutron client. A Neutron client is needed to retrieve subnet ids. If omitted, the region argument of the provider is used.
subnetId String
The ID of the subnet.
subnetpoolId String
The ID of the subnetpool associated with the subnet.
tags List<String>
The list of subnet tags to filter.
tenantId String
The owner of the subnet.
cidr string
The CIDR of the subnet.
description string
Human-readable description of the subnet.
dhcpEnabled boolean
If the subnet has DHCP enabled.
dnsPublishFixedIp boolean
If the subnet publishes DNS records.
gatewayIp string
The IP of the subnet's gateway.
ipVersion number
The IP version of the subnet (either 4 or 6).
ipv6AddressMode Changes to this property will trigger replacement. string
The IPv6 address mode. Valid values are dhcpv6-stateful, dhcpv6-stateless, or slaac.
ipv6RaMode Changes to this property will trigger replacement. string
The IPv6 Router Advertisement mode. Valid values are dhcpv6-stateful, dhcpv6-stateless, or slaac.
name string
The name of the subnet.
networkId string
The ID of the network the subnet belongs to.
region Changes to this property will trigger replacement. string
The region in which to obtain the V2 Neutron client. A Neutron client is needed to retrieve subnet ids. If omitted, the region argument of the provider is used.
subnetId string
The ID of the subnet.
subnetpoolId string
The ID of the subnetpool associated with the subnet.
tags string[]
The list of subnet tags to filter.
tenantId string
The owner of the subnet.
cidr str
The CIDR of the subnet.
description str
Human-readable description of the subnet.
dhcp_enabled bool
If the subnet has DHCP enabled.
dns_publish_fixed_ip bool
If the subnet publishes DNS records.
gateway_ip str
The IP of the subnet's gateway.
ip_version int
The IP version of the subnet (either 4 or 6).
ipv6_address_mode Changes to this property will trigger replacement. str
The IPv6 address mode. Valid values are dhcpv6-stateful, dhcpv6-stateless, or slaac.
ipv6_ra_mode Changes to this property will trigger replacement. str
The IPv6 Router Advertisement mode. Valid values are dhcpv6-stateful, dhcpv6-stateless, or slaac.
name str
The name of the subnet.
network_id str
The ID of the network the subnet belongs to.
region Changes to this property will trigger replacement. str
The region in which to obtain the V2 Neutron client. A Neutron client is needed to retrieve subnet ids. If omitted, the region argument of the provider is used.
subnet_id str
The ID of the subnet.
subnetpool_id str
The ID of the subnetpool associated with the subnet.
tags Sequence[str]
The list of subnet tags to filter.
tenant_id str
The owner of the subnet.
cidr String
The CIDR of the subnet.
description String
Human-readable description of the subnet.
dhcpEnabled Boolean
If the subnet has DHCP enabled.
dnsPublishFixedIp Boolean
If the subnet publishes DNS records.
gatewayIp String
The IP of the subnet's gateway.
ipVersion Number
The IP version of the subnet (either 4 or 6).
ipv6AddressMode Changes to this property will trigger replacement. String
The IPv6 address mode. Valid values are dhcpv6-stateful, dhcpv6-stateless, or slaac.
ipv6RaMode Changes to this property will trigger replacement. String
The IPv6 Router Advertisement mode. Valid values are dhcpv6-stateful, dhcpv6-stateless, or slaac.
name String
The name of the subnet.
networkId String
The ID of the network the subnet belongs to.
region Changes to this property will trigger replacement. String
The region in which to obtain the V2 Neutron client. A Neutron client is needed to retrieve subnet ids. If omitted, the region argument of the provider is used.
subnetId String
The ID of the subnet.
subnetpoolId String
The ID of the subnetpool associated with the subnet.
tags List<String>
The list of subnet tags to filter.
tenantId String
The owner of the subnet.

getSubnet Result

The following output properties are available:

AllTags List<string>
A set of string tags applied on the subnet.
AllocationPools List<Pulumi.OpenStack.Networking.Outputs.GetSubnetAllocationPool>
Allocation pools of the subnet.
Cidr string
Description string
DnsNameservers List<string>
DNS Nameservers of the subnet.
EnableDhcp bool
Whether the subnet has DHCP enabled or not.
GatewayIp string
HostRoutes List<Pulumi.OpenStack.Networking.Outputs.GetSubnetHostRoute>
Host Routes of the subnet.
Id string
The provider-assigned unique ID for this managed resource.
IpVersion int
Ipv6AddressMode string
Ipv6RaMode string
Name string
NetworkId string
Region string
See Argument Reference above.
ServiceTypes List<string>
Service types of the subnet.
SubnetId string
SubnetpoolId string
TenantId string
DhcpEnabled bool
DnsPublishFixedIp bool
Tags List<string>
AllTags []string
A set of string tags applied on the subnet.
AllocationPools []GetSubnetAllocationPool
Allocation pools of the subnet.
Cidr string
Description string
DnsNameservers []string
DNS Nameservers of the subnet.
EnableDhcp bool
Whether the subnet has DHCP enabled or not.
GatewayIp string
HostRoutes []GetSubnetHostRoute
Host Routes of the subnet.
Id string
The provider-assigned unique ID for this managed resource.
IpVersion int
Ipv6AddressMode string
Ipv6RaMode string
Name string
NetworkId string
Region string
See Argument Reference above.
ServiceTypes []string
Service types of the subnet.
SubnetId string
SubnetpoolId string
TenantId string
DhcpEnabled bool
DnsPublishFixedIp bool
Tags []string
allTags List<String>
A set of string tags applied on the subnet.
allocationPools List<GetSubnetAllocationPool>
Allocation pools of the subnet.
cidr String
description String
dnsNameservers List<String>
DNS Nameservers of the subnet.
enableDhcp Boolean
Whether the subnet has DHCP enabled or not.
gatewayIp String
hostRoutes List<GetSubnetHostRoute>
Host Routes of the subnet.
id String
The provider-assigned unique ID for this managed resource.
ipVersion Integer
ipv6AddressMode String
ipv6RaMode String
name String
networkId String
region String
See Argument Reference above.
serviceTypes List<String>
Service types of the subnet.
subnetId String
subnetpoolId String
tenantId String
dhcpEnabled Boolean
dnsPublishFixedIp Boolean
tags List<String>
allTags string[]
A set of string tags applied on the subnet.
allocationPools GetSubnetAllocationPool[]
Allocation pools of the subnet.
cidr string
description string
dnsNameservers string[]
DNS Nameservers of the subnet.
enableDhcp boolean
Whether the subnet has DHCP enabled or not.
gatewayIp string
hostRoutes GetSubnetHostRoute[]
Host Routes of the subnet.
id string
The provider-assigned unique ID for this managed resource.
ipVersion number
ipv6AddressMode string
ipv6RaMode string
name string
networkId string
region string
See Argument Reference above.
serviceTypes string[]
Service types of the subnet.
subnetId string
subnetpoolId string
tenantId string
dhcpEnabled boolean
dnsPublishFixedIp boolean
tags string[]
all_tags Sequence[str]
A set of string tags applied on the subnet.
allocation_pools Sequence[GetSubnetAllocationPool]
Allocation pools of the subnet.
cidr str
description str
dns_nameservers Sequence[str]
DNS Nameservers of the subnet.
enable_dhcp bool
Whether the subnet has DHCP enabled or not.
gateway_ip str
host_routes Sequence[GetSubnetHostRoute]
Host Routes of the subnet.
id str
The provider-assigned unique ID for this managed resource.
ip_version int
ipv6_address_mode str
ipv6_ra_mode str
name str
network_id str
region str
See Argument Reference above.
service_types Sequence[str]
Service types of the subnet.
subnet_id str
subnetpool_id str
tenant_id str
dhcp_enabled bool
dns_publish_fixed_ip bool
tags Sequence[str]
allTags List<String>
A set of string tags applied on the subnet.
allocationPools List<Property Map>
Allocation pools of the subnet.
cidr String
description String
dnsNameservers List<String>
DNS Nameservers of the subnet.
enableDhcp Boolean
Whether the subnet has DHCP enabled or not.
gatewayIp String
hostRoutes List<Property Map>
Host Routes of the subnet.
id String
The provider-assigned unique ID for this managed resource.
ipVersion Number
ipv6AddressMode String
ipv6RaMode String
name String
networkId String
region String
See Argument Reference above.
serviceTypes List<String>
Service types of the subnet.
subnetId String
subnetpoolId String
tenantId String
dhcpEnabled Boolean
dnsPublishFixedIp Boolean
tags List<String>

Supporting Types

GetSubnetAllocationPool

End This property is required. string
Start This property is required. string
End This property is required. string
Start This property is required. string
end This property is required. String
start This property is required. String
end This property is required. string
start This property is required. string
end This property is required. str
start This property is required. str
end This property is required. String
start This property is required. String

GetSubnetHostRoute

DestinationCidr This property is required. string
NextHop This property is required. string
DestinationCidr This property is required. string
NextHop This property is required. string
destinationCidr This property is required. String
nextHop This property is required. String
destinationCidr This property is required. string
nextHop This property is required. string
destination_cidr This property is required. str
next_hop This property is required. str
destinationCidr This property is required. String
nextHop This property is required. String

Package Details

Repository
OpenStack pulumi/pulumi-openstack
License
Apache-2.0
Notes
This Pulumi package is based on the openstack Terraform Provider.
OpenStack v5.0.3 published on Wednesday, Feb 12, 2025 by Pulumi