---
title: "openstack_networking_subnet_v2"
description: ""
sidebar_position: 14
---

# openstack\_networking\_subnet\_v2

:::info

This instruction is a copy of the official documentation for the OpenStack Terraform provider in the [Terraform Registry](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs).

:::

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

## Example Usage \{#example-usage}

```hcl
data "openstack_networking_subnet_v2" "subnet_1" {
  name = "subnet_1"
}
```

## Argument Reference \{#argument-reference}

* `region` - (optional) 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.

* `name` - (Optional) The name of the subnet.

* `description` - (Optional) Human-readable description of the subnet.

* `dhcp_enabled` - (Optional) Whether DHCP is enabled for the subnet.

* `network_id` - (Optional) The ID of the network the subnet belongs to.

* `tenant_id` - (Optional) The owner of the subnet.

* `ip_version` - (Optional) The IP version of the subnet (4 or 6).

* `gateway_ip` - (Optional) The IP address of the subnet gateway.

* `cidr` - (Optional) The CIDR of the subnet.

* `subnet_id` - (Optional) The ID of the subnet.

* `ipv6_address_mode` - (Optional) The IPv6 address mode. Valid values are `dhcpv6-stateful`, `dhcpv6-stateless`, or `slaac`.

* `ipv6_ra_mode` - (Optional) The IPv6 Router Advertisement mode. Valid values are `dhcpv6-stateful`, `dhcpv6-stateless`, or `slaac`.

* `subnetpool_id` - (Optional) The ID of the subnet pool associated with the subnet.

* `tags` - (Optional) A list of subnet tags for filtering.

## Attributes Reference \{#attributes-reference}

`id` is set to the ID of the found subnet. In addition, the following attributes are exported:

* `allocation_pools` - Allocation pools for the subnet.
* `enable_dhcp` - Whether DHCP is enabled for the subnet.
* `dns_nameservers` - DNS nameservers for the subnet.
* `service_types` - Service types for the subnet.
* `host_routes` - Host routes for the subnet.
* `region` - See the Argument Reference above.
* `all_tags` - A set of string tags applied to the subnet.
