OpenStack v5.0.3 published on Wednesday, Feb 12, 2025 by Pulumi
openstack.networking.getSubnet
Explore with Pulumi AI
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",
});
import pulumi
import pulumi_openstack as openstack
subnet1 = openstack.networking.get_subnet(name="subnet_1")
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
	})
}
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",
    });
});
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());
    }
}
variables:
  subnet1:
    fn::invoke:
      function: openstack:networking:getSubnet
      arguments:
        name: subnet_1
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>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]func LookupSubnet(ctx *Context, args *LookupSubnetArgs, opts ...InvokeOption) (*LookupSubnetResult, error)
func LookupSubnetOutput(ctx *Context, args *LookupSubnetOutputArgs, opts ...InvokeOption) LookupSubnetResultOutput> 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)
}public static CompletableFuture<GetSubnetResult> getSubnet(GetSubnetArgs args, InvokeOptions options)
public static Output<GetSubnetResult> getSubnet(GetSubnetArgs args, InvokeOptions options)
fn::invoke:
  function: openstack:networking/getSubnet:getSubnet
  arguments:
    # arguments dictionaryThe 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.
- DnsPublish boolFixed Ip 
- 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 string
- The IPv6 address mode. Valid values are
dhcpv6-stateful,dhcpv6-stateless, orslaac.
- Ipv6RaMode string
- The IPv6 Router Advertisement mode. Valid values
are dhcpv6-stateful,dhcpv6-stateless, orslaac.
- Name string
- The name of the subnet.
- NetworkId string
- The ID of the network the subnet belongs to.
- Region string
- The region in which to obtain the V2 Neutron client.
A Neutron client is needed to retrieve subnet ids. If omitted, the
regionargument of the provider is used.
- SubnetId string
- The ID of the subnet.
- SubnetpoolId string
- The ID of the subnetpool associated with the subnet.
- 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.
- DnsPublish boolFixed Ip 
- 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 string
- The IPv6 address mode. Valid values are
dhcpv6-stateful,dhcpv6-stateless, orslaac.
- Ipv6RaMode string
- The IPv6 Router Advertisement mode. Valid values
are dhcpv6-stateful,dhcpv6-stateless, orslaac.
- Name string
- The name of the subnet.
- NetworkId string
- The ID of the network the subnet belongs to.
- Region string
- The region in which to obtain the V2 Neutron client.
A Neutron client is needed to retrieve subnet ids. If omitted, the
regionargument of the provider is used.
- SubnetId string
- The ID of the subnet.
- SubnetpoolId string
- The ID of the subnetpool associated with the subnet.
- []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.
- dnsPublish BooleanFixed Ip 
- 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 String
- The IPv6 address mode. Valid values are
dhcpv6-stateful,dhcpv6-stateless, orslaac.
- ipv6RaMode String
- The IPv6 Router Advertisement mode. Valid values
are dhcpv6-stateful,dhcpv6-stateless, orslaac.
- name String
- The name of the subnet.
- networkId String
- The ID of the network the subnet belongs to.
- region String
- The region in which to obtain the V2 Neutron client.
A Neutron client is needed to retrieve subnet ids. If omitted, the
regionargument of the provider is used.
- subnetId String
- The ID of the subnet.
- subnetpoolId String
- The ID of the subnetpool associated with the subnet.
- 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.
- dnsPublish booleanFixed Ip 
- 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 string
- The IPv6 address mode. Valid values are
dhcpv6-stateful,dhcpv6-stateless, orslaac.
- ipv6RaMode string
- The IPv6 Router Advertisement mode. Valid values
are dhcpv6-stateful,dhcpv6-stateless, orslaac.
- name string
- The name of the subnet.
- networkId string
- The ID of the network the subnet belongs to.
- region string
- The region in which to obtain the V2 Neutron client.
A Neutron client is needed to retrieve subnet ids. If omitted, the
regionargument of the provider is used.
- subnetId string
- The ID of the subnet.
- subnetpoolId string
- The ID of the subnetpool associated with the subnet.
- 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_ boolfixed_ ip 
- 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_ strmode 
- The IPv6 address mode. Valid values are
dhcpv6-stateful,dhcpv6-stateless, orslaac.
- ipv6_ra_ strmode 
- The IPv6 Router Advertisement mode. Valid values
are dhcpv6-stateful,dhcpv6-stateless, orslaac.
- name str
- The name of the subnet.
- network_id str
- The ID of the network the subnet belongs to.
- region str
- The region in which to obtain the V2 Neutron client.
A Neutron client is needed to retrieve subnet ids. If omitted, the
regionargument 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.
- 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.
- dnsPublish BooleanFixed Ip 
- 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 String
- The IPv6 address mode. Valid values are
dhcpv6-stateful,dhcpv6-stateless, orslaac.
- ipv6RaMode String
- The IPv6 Router Advertisement mode. Valid values
are dhcpv6-stateful,dhcpv6-stateless, orslaac.
- name String
- The name of the subnet.
- networkId String
- The ID of the network the subnet belongs to.
- region String
- The region in which to obtain the V2 Neutron client.
A Neutron client is needed to retrieve subnet ids. If omitted, the
regionargument of the provider is used.
- subnetId String
- The ID of the subnet.
- subnetpoolId String
- The ID of the subnetpool associated with the subnet.
- List<String>
- The list of subnet tags to filter.
- tenantId String
- The owner of the subnet.
getSubnet Result
The following output properties are available:
- List<string>
- A set of string tags applied on the subnet.
- AllocationPools List<Pulumi.Open Stack. Networking. Outputs. Get Subnet Allocation Pool> 
- 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.Open Stack. Networking. Outputs. Get Subnet Host Route> 
- 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
- DnsPublish boolFixed Ip 
- List<string>
- []string
- A set of string tags applied on the subnet.
- AllocationPools []GetSubnet Allocation Pool 
- 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 []GetSubnet Host Route 
- 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
- DnsPublish boolFixed Ip 
- []string
- List<String>
- A set of string tags applied on the subnet.
- allocationPools List<GetSubnet Allocation Pool> 
- 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<GetSubnet Host Route> 
- 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
- dnsPublish BooleanFixed Ip 
- List<String>
- string[]
- A set of string tags applied on the subnet.
- allocationPools GetSubnet Allocation Pool[] 
- 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 GetSubnet Host Route[] 
- 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
- dnsPublish booleanFixed Ip 
- string[]
- Sequence[str]
- A set of string tags applied on the subnet.
- allocation_pools Sequence[GetSubnet Allocation Pool] 
- 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[GetSubnet Host Route] 
- Host Routes of the subnet.
- id str
- The provider-assigned unique ID for this managed resource.
- ip_version int
- ipv6_address_ strmode 
- ipv6_ra_ strmode 
- 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_ boolfixed_ ip 
- Sequence[str]
- 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
- dnsPublish BooleanFixed Ip 
- List<String>
Supporting Types
GetSubnetAllocationPool   
GetSubnetHostRoute   
- DestinationCidr string
- NextHop string
- DestinationCidr string
- NextHop string
- destinationCidr String
- nextHop String
- destinationCidr string
- nextHop string
- destination_cidr str
- next_hop str
- destinationCidr String
- nextHop String
Package Details
- Repository
- OpenStack pulumi/pulumi-openstack
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the openstackTerraform Provider.