Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ovh_cloud_project_network_private_subnet_v2 network_id is not compatible with ovh_cloud_project_network_private id #833

Open
sakel opened this issue Feb 9, 2025 · 2 comments

Comments

@sakel
Copy link

sakel commented Feb 9, 2025

Describe the bug

resource "ovh_cloud_project_network_private" "privnet" {
service_name = var.service
name = var.network_name
regions = [var.region]
}

resource "ovh_cloud_project_network_private_subnet_v2" "privnet_subnet" {
service_name = ovh_cloud_project_network_private.privnet.service_name
network_id = ovh_cloud_project_network_private.privnet.id
name = "private-subnet"
region = var.region
dns_nameservers = ["8.8.8.8"]
cidr = var.ip_range
dhcp = true
enable_gateway_ip = true
use_default_public_dns_resolver = true
}

produces the following error:

│ Error: calling POST /cloud/project/<project_id>/region//network/pn-123456_0/subnet with params &{private-subnet 10.99.0.0/16 4 [] [8.8.8.8] [] true true 0x1400000ed60}:
│ "OVHcloud API error (status code 400): Client::BadRequest: "invalid: invalid uuid 'pn-123456_0': invalid UUID length: 12" (X-OVH-Query-Id: EU.ext-4.67a9f19e.3691819.23b1cae19716ba7ee48ca2db5ef80ebf)"

which indicates that the id of the private network does not match the id required by ovh_cloud_project_network_private_subnet_v2, because it needs to be a UUID

Terraform Version

1.10.4

OVH Terraform Provider Version

1.6.0

Affected Resource(s)

Please list the resources as a list, for example:

  • ovh_cloud_project_network_private_subnet_v2
  • ovh_cloud_project_network_private

Terraform Configuration Files

resource "ovh_cloud_project_network_private" "privnet" {
service_name = var.service
name = var.network_name
regions = [var.region]
}

resource "ovh_cloud_project_network_private_subnet_v2" "privnet_subnet" {
service_name = ovh_cloud_project_network_private.privnet.service_name
network_id = ovh_cloud_project_network_private.privnet.id
name = "private-subnet"
region = var.region
dns_nameservers = ["8.8.8.8"]
cidr = var.ip_range
dhcp = true
enable_gateway_ip = true
use_default_public_dns_resolver = true
}

Debug Output

│ Error: calling POST /cloud/project/<project_id>/region//network/pn-123456_0/subnet with params &{private-subnet 10.99.0.0/16 4 [] [8.8.8.8] [] true true 0x1400000ed60}:
│ "OVHcloud API error (status code 400): Client::BadRequest: "invalid: invalid uuid 'pn-123456_0': invalid UUID length: 12" (X-OVH-Query-Id: EU.ext-4.67a9f19e.3691819.23b1cae19716ba7ee48ca2db5ef80ebf)"

Expected Behavior

Being able to pass the id of the generated network programmatically like it is possible with v1.

Actual Behavior

We got an error saying that the Id given is not a UUID

Steps to Reproduce

  1. terraform apply

Additional context

We're trying to set DNS settings for the private network, which is possible only with ovh_cloud_project_network_private_subnet_v2, which doesn't work in conjunction with ovh_cloud_project_network_private.

@amstuta
Copy link
Contributor

amstuta commented Feb 10, 2025

Hello @sakel,

Indeed you can't directly use the id of resource ovh_cloud_project_network_private in the subnet. However the id that you need to use (the OpenStack id) is also in the resource, you can use the following configuration:

variable "netregion" {
    type = string
    default = "GRA9"
}

resource "ovh_cloud_project_network_private" "privnet" {
  service_name = "<public cloud project id>"
  name = "test"
  regions = [var.netregion]
  vlan_id = 10
}

resource "ovh_cloud_project_network_private_subnet_v2" "privnet_subnet" {
  service_name = ovh_cloud_project_network_private.privnet.service_name
  network_id = element([for region in ovh_cloud_project_network_private.privnet.regions_attributes: region if "${region.region}" == var.netregion], 0).openstackid
  name = "private-subnet"
  region = var.netregion
  dns_nameservers = ["8.8.8.8"]
  cidr = "10.10.12.0/24"
  dhcp = true
  enable_gateway_ip = true
  use_default_public_dns_resolver = false
}

@marclamy
Copy link

Greetings, @sakel & @amstuta!

While this solution works, I doubt this is the intended or definitive experience for such simple use cases?

From my understanding, the issue comes from ovh_cloud_project_network_private_subnet_v2 relying on the underlying OpenStack network id, which can also be solved like this, using the OpenStack provider (as is suggested in the OVHCloud Terraform guide):

variable "netregion" {
    type = string
    default = "GRA9"
}

resource "ovh_cloud_project_network_private" "privnet" {
  service_name = "<public cloud project id>"
  name = "test"
  regions = [var.netregion]
  vlan_id = 10
}

data "openstack_networking_network_v2" "os_privnet" {
  name = ovh_cloud_project_network_private.privnet.name
}

resource "ovh_cloud_project_network_private_subnet_v2" "privnet_subnet" {
  service_name = ovh_cloud_project_network_private.privnet.service_name
  network_id   = data.openstack_networking_network_v2.os_privnet.id
  name = "private-subnet"
  region = var.netregion
  dns_nameservers = ["8.8.8.8"]
  cidr = "10.10.12.0/24"
  dhcp = true
  enable_gateway_ip = true
  use_default_public_dns_resolver = false
}

This is a bit cleaner, in my opinion, but still not a satsfying experience from an OVH Cloud user's point of view.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants