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] "Invalid region" error when using OVH Terraform module ovh_cloud_project_network_private and Local Zone #802

Closed
jtrebaol opened this issue Jan 14, 2025 · 7 comments · Fixed by #808 or #824

Comments

@jtrebaol
Copy link

Describe the bug

Issue is only observed with Terraform module "ovh_cloud_project_network_private" and Local Zone. No issue with module OpenStack "openstack_networking_network_v2"

Terraform Version

OpenTofu v1.8.5

OVH Terraform Provider Version

  • Using previously-installed terraform-provider-openstack/openstack v3.0.0
  • Using previously-installed ovh/ovh v1.1.0
  • Using previously-installed hashicorp/null v3.2.3
  • Using previously-installed hashicorp/template v2.2.0
  • Using previously-installed hashicorp/aws v4.67.0
  • Using previously-installed ansible/ansible v1.3.0

Affected Resource(s)

Please list the resources as a list, for example:

  • ovh_cloud_project_network_private
  • ovh_cloud_project_network_private_subnet

Terraform Configuration Files

# Case NOK:
 resource "ovh_cloud_project_network_private" "test" {
  service_name = "2f23ff001e304c81a88c728cf68c739e"
  name         = "madrid"
  regions      = ["EU-SOUTH-LZ-MAD-A"]
  provider     = ovh.ovh
  vlan_id      = 0 
 }

# Case OK:
resource "openstack_networking_network_v2" "network-mad" {
name = "test_mad"
admin_state_up = "true"
region = "EU-SOUTH-LZ-MAD-A"
}

Debug Output

│ Error: calling /cloud/project/2f23ff001e304c81a88c728cf68c739e/network/private with params projectId: 2f23ff001e304c81a88c728cf68c739e, vlanId:98, name: Private_network_MAD, regions: [EU-SOUTH-LZ-MAD-A]:
│ "OVHcloud API error (status code 400): Client::BadRequest: "Invalid region EU-SOUTH-LZ-MAD-A" (X-OVH-Query-Id: EU.ext-4.677f8595.2300585.24b33c1c8894afd19f753b041caea0fb)"

Expected Behavior

ovh_cloud_project_network_private and ovh_cloud_project_network_private_subnet shall support Local Zones region

Actual Behavior

Seems the Local Zones region are not supported yet on ovh modules

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. create the network.tf file with above example
  2. 'tofu apply'

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

  • Case issue open with OVH support team, reference CS10627686
@amstuta
Copy link
Contributor

amstuta commented Jan 15, 2025

Hello @jtrebaol,

You are right, the resource ovh_cloud_project_network_private is indeed not able to interact with local zones.
It is due to the fact that this resource relies on the legacy API route POST /cloud/project/{serviceName}/network/private and not on the new one POST /cloud/project/{serviceName}/region/{regionName}/network.

After checking, we have no easy way to update the current resource to handle the local zones, so we will add a new resource ovh_cloud_project_network_private_v2 shortly.

@jtrebaol
Copy link
Author

Thanks @amstuta for your analysis

@jtrebaol
Copy link
Author

jtrebaol commented Feb 4, 2025

Hello @amstuta

In which Terraform ovh provider release this bug is fixed?

Thanks

@amstuta
Copy link
Contributor

amstuta commented Feb 4, 2025

Hello @jtrebaol, you can use the new resource ovh_cloud_project_region_network that comes with release v1.5.0.

@jtrebaol
Copy link
Author

jtrebaol commented Feb 4, 2025

Hello @jtrebaol, you can use the new resource ovh_cloud_project_region_network that comes with release v1.5.0.

Following test, seems the subnet { start / end } arguments for allocation_pool are not taken into account:

==> Resource added

resource "ovh_cloud_project_region_network" "networks" {
  service_name = var.service_name
  region_name  = "EU-SOUTH-LZ-MAD-A"
  name         = "Private_network_MAD"
  provider     = ovh.ovh
  subnet       = {
    cidr              = "10.10.232.0/24"
    enable_dhcp       = false
    enable_gateway_ip = false
    start   = "10.10.232.50"
    end     = "10.10.232.100"
    ip_version        = 4
   }
}

==> tofu apply

  # module.ovh_network.ovh_cloud_project_region_network.networks["EU-WEST-LZ-ZRH-A"] will be created
  + resource "ovh_cloud_project_region_network" "networks" {
      + id           = (known after apply)
      + name         = "Private_network_ZRH"
      + region       = (known after apply)
      + region_name  = "EU-WEST-LZ-ZRH-A"
      + service_name = "2f23ff001e304c81a88c728cf68c739e"
      + subnet       = {
          + cidr              = "10.10.236.0/24"
          + enable_dhcp       = false
          + enable_gateway_ip = false
          + ip_version        = 4
        }
      + visibility   = (known after apply)
      + vlan_id      = (known after apply)
    }

==> Result: allocation pool is set to 10.10.232.1 - 10.10.232.254 which is not expected

$ tofu state show module.ovh_network.ovh_cloud_project_region_network.networks[\"EU-SOUTH-LZ-MAD-A\"]
# module.ovh_network.ovh_cloud_project_region_network.networks["EU-SOUTH-LZ-MAD-A"]:
resource "ovh_cloud_project_region_network" "networks" {
    id           = "3216a768-f5e9-4a23-a139-d4427c46df9c"
    name         = "Private_network_MAD"
    region_name  = "EU-SOUTH-LZ-MAD-A"
    service_name = "2f23ff001e304c81a88c728cf68c739e"
    subnet       = {
        cidr              = "10.10.232.0/24"
        enable_dhcp       = false
        enable_gateway_ip = false
        ip_version        = 4
    }
    visibility   = "private"
}

@amstuta
Copy link
Contributor

amstuta commented Feb 4, 2025

Hello @jtrebaol, there are two issues here:

  • The documentation is rendered badly: the fields start and end should be placed in a field allocation_pools like this:
allocation_pools = [
  {
    start   = "10.10.232.50"
    end     = "10.10.232.100"
  }
]

I'll check to fix the doc.

  • There is a second issue even when declaring the field properly (the resource must be replaced at each apply when declaring allocation pools). I'll check this quickly and re-open this issue to track the progress.

@amstuta
Copy link
Contributor

amstuta commented Feb 5, 2025

Fix has been merged and will be released in a few days.

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