diff --git a/builtin/providers/openstack/resource_openstack_networking_subnet.go b/builtin/providers/openstack/resource_openstack_networking_subnet.go index bedad5572..0f52c0be2 100644 --- a/builtin/providers/openstack/resource_openstack_networking_subnet.go +++ b/builtin/providers/openstack/resource_openstack_networking_subnet.go @@ -270,7 +270,11 @@ func resourceSubnetAllocationPools(d *schema.ResourceData) []subnets.AllocationP rawAPs := d.Get("allocation_pools").([]interface{}) aps := make([]subnets.AllocationPool, len(rawAPs)) for i, raw := range rawAPs { - aps[i] = raw.(subnets.AllocationPool) + rawMap := raw.(map[string]interface{}) + aps[i] = subnets.AllocationPool{ + Start: rawMap["start"].(string), + End: rawMap["end"].(string), + } } return aps } @@ -288,7 +292,11 @@ func resourceSubnetHostRoutes(d *schema.ResourceData) []subnets.HostRoute { rawHR := d.Get("host_routes").([]interface{}) hr := make([]subnets.HostRoute, len(rawHR)) for i, raw := range rawHR { - hr[i] = raw.(subnets.HostRoute) + rawMap := raw.(map[string]interface{}) + hr[i] = subnets.HostRoute{ + DestinationCIDR: rawMap["destination_cidr"].(string), + NextHop: rawMap["next_hop"].(string), + } } return hr } diff --git a/website/source/docs/providers/openstack/r/networking_subnet.html.markdown b/website/source/docs/providers/openstack/r/networking_subnet.html.markdown new file mode 100644 index 000000000..f9ab4f6ed --- /dev/null +++ b/website/source/docs/providers/openstack/r/networking_subnet.html.markdown @@ -0,0 +1,92 @@ +--- +layout: "openstack" +page_title: "OpenStack: openstack_networking_subnet" +sidebar_current: "docs-openstack-resource-networking-subnet" +description: |- + Manages a Neutron subnet resource within OpenStack. +--- + +# openstack\_networking\_subnet + +Manages a Neutron subnet resource within OpenStack. + +## Example Usage + +``` +resource "openstack_networking_network" "network_1" { + name = "tf_test_network" + admin_state_up = "true" +} + +resource "openstack_networking_subnet" "subnet_1" { + network_id = "${openstack_networking_network.network_1.id}" + cidr = "192.168.199.0/24" + ip_version = 4 +} +``` + +## Argument Reference + +The following arguments are supported: + +* `network_id` - (Required) The UUID of the parent network. Changing this + creates a new subnet. + +* `cidr` - (Required) CIDR representing IP range for this subnet, based on IP + version. Changing this creates a new subnet. + +* `ip_version` - (Required) IP version, either 4 or 6. Changing this creates a + new subnet. + +* `name` - (Optional) The name of the subnet. Changing this updates the name of + the existing subnet. + +* `tenant_id` - (Optional) The owner of the subnet. Required if admin wants to + create a subnet for another tenant. Changing this creates a new subnet. + +* `allocation_pools` - (Optional) An array of sub-ranges of CIDR available for + dynamic allocation to ports. The allocation_pool object structure is + documented below. Changing this creates a new subnet. + +* `gateway_ip` - (Optional) Default gateway used by devices in this subnet. + Changing this updates the gateway IP of the existing subnet. + +* `enable_dhcp` - (Optional) The administrative state of the network. + Acceptable values are "true" and "false". Changing this value enables or + disables the DHCP capabilities of the existing subnet. + +* `dns_nameservers` - (Optional) An array of DNS name server names used by hosts + in this subnet. Changing this updates the DNS name servers for the existing + subnet. + +* `host_routes` - (Optional) An array of routes that should be used by devices + with IPs from this subnet (not including local subnet route). The host_route + object structure is documented below. Changing this updates the host routes + for the existing subnet. + +The `allocation_pools` block supports: + +* `start` - (Required) The starting address. + +* `end` - (Required) The ending address. + +The `host_routes` block supports: + +* `destination_cidr` - (Required) The destination CIDR. + +* `next_hop` - (Required) The next hop in the route. + +## Attributes Reference + +The following attributes are exported: + +* `network_id` - See Argument Reference above. +* `cidr` - See Argument Reference above. +* `ip_version` - See Argument Reference above. +* `name` - See Argument Reference above. +* `tenant_id` - See Argument Reference above. +* `allocation_pools` - See Argument Reference above. +* `gateway_ip` - See Argument Reference above. +* `enable_dhcp` - See Argument Reference above. +* `dns_nameservers` - See Argument Reference above. +* `host_routes` - See Argument Reference above.