terraform-provider-ovh icon indicating copy to clipboard operation
terraform-provider-ovh copied to clipboard

Adding gateway and gateway interface resources

Open durandx opened this issue 2 years ago • 8 comments

Adding 2 new resources :

  • ovh_cloud_project_gateway
  • ovh_cloud_project_gateway_interface

durandx avatar Jan 09 '23 11:01 durandx

@durandx : did you know that you can already create a gateway with the openstack provider ?

This page may help https://docs.ovh.com/gb/en/api/terraform-at-ovhcloud/

yomovh avatar Jan 19 '23 16:01 yomovh

@scraly Thank you for your review and advices for this pull request. Unfortunately, right now, I have no time to work on acceptance tests and documentation + datasources...

@yomovh Yes, that's what we used in the first place, but we were facing a problem for attaching an interface for a gateway created with openstack provider (maybe because we need to define a size for the gateway). Using the OVH API solved this problem, that's why we added this resource (in the ovh provider) using the OVH API.

durandx avatar Jan 23 '23 15:01 durandx

@durandx

Thanks for the contribution :) If you haven't the time to create documentation and acceptance tests, can you copy/paste to us an example of ovh_cloud_project_gateway and ovh_cloud_project_gateway_interface configuration?

Thanks :)

scraly avatar Feb 13 '23 15:02 scraly

Hi,

I succesfully created a gateway but when I want to create a gateway_interface I have an issue:

$ terraform apply

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # ovh_cloud_project_gateway.my-gateway will be created
  + resource "ovh_cloud_project_gateway" "my-gateway" {
      + id           = (known after apply)
      + model        = "s"
      + name         = "my_gateway"
      + network_id   = (known after apply)
      + region       = "GRA5"
      + service_name = "xxxx"
      + status       = (known after apply)
      + subnet_id    = (known after apply)
    }

  # ovh_cloud_project_gateway_interface.my-gateway-interface will be created
  + resource "ovh_cloud_project_gateway_interface" "my-gateway-interface" {
      + gateway_id   = (known after apply)
      + id           = (known after apply)
      + ip           = (known after apply)
      + network_id   = (known after apply)
      + region       = "GRA5"
      + service_name = "xxxx"
      + subnet_id    = (known after apply)
    }

  # ovh_cloud_project_network_private.network will be created
  + resource "ovh_cloud_project_network_private" "network" {
      + id                 = (known after apply)
      + name               = "my_private_network"
      + regions            = [
          + "GRA5",
        ]
      + regions_attributes = (known after apply)
      + regions_status     = (known after apply)
      + service_name       = "xxxxx"
      + status             = (known after apply)
      + type               = (known after apply)
      + vlan_id            = 0
    }

  # ovh_cloud_project_network_private_subnet.networksubnet will be created
  + resource "ovh_cloud_project_network_private_subnet" "networksubnet" {
      + cidr         = (known after apply)
      + dhcp         = true
      + end          = "192.168.168.200"
      + gateway_ip   = (known after apply)
      + id           = (known after apply)
      + ip_pools     = (known after apply)
      + network      = "192.168.168.0/24"
      + network_id   = (known after apply)
      + no_gateway   = false
      + region       = "GRA5"
      + service_name = "xxxx"
      + start        = "192.168.168.100"
    }

Plan: 4 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

ovh_cloud_project_network_private.network: Creating...
ovh_cloud_project_network_private.network: Still creating... [10s elapsed]
ovh_cloud_project_network_private.network: Still creating... [20s elapsed]
ovh_cloud_project_network_private.network: Creation complete after 27s [id=pn-xxxxxx_0]
ovh_cloud_project_network_private_subnet.networksubnet: Creating...
ovh_cloud_project_network_private_subnet.networksubnet: Creation complete after 5s [id=xxxx-xxxx-xxx-xxx-xxx]
ovh_cloud_project_gateway.my-gateway: Creating...
ovh_cloud_project_gateway.my-gateway: Still creating... [10s elapsed]
ovh_cloud_project_gateway.my-gateway: Still creating... [20s elapsed]
ovh_cloud_project_gateway.my-gateway: Creation complete after 24s [id=xx-xx-xx-xx-xxxx]
ovh_cloud_project_gateway_interface.my-gateway-interface: Creating...
╷
│ Error: calling /cloud/project/xxxx/region/GRA5/gateway/xxx-xxxx-xxx-xx-xxxx/interface with params subnetId: xxxxx-xxx-xxxx-xxxx-xxxx:
│ 	 "HTTP Error 409: Client::Conflict: \"conflict: subnet xxxxcxxxxfxxx-xxx-xxxx-xxx already added to gateway\" (X-OVH-Query-Id: EU.ext-xxxxx.xxxx1.cxxxxxxe-xxx-xxx-xxx-xxx)"
│
│   with ovh_cloud_project_gateway_interface.my-gateway-interface,
│   on pr358.tf line 32, in resource "ovh_cloud_project_gateway_interface" "my-gateway-interface":
│   32: resource "ovh_cloud_project_gateway_interface" "my-gateway-interface" {
│

scraly avatar Feb 14 '23 06:02 scraly

Hi,

@scraly

We didn't run into this issue, probably because we used more than 1 subnet for the gateway. We have declared the first subnet to the Gateway resource (with ovh_cloud_project_gateway.gateway) and the others subnets have been attached to the gateway_interface (with ovh_cloud_project_gateway_interface.gateway_interface). The Gateway resource use the API endpoint POST "/cloud/project/%s/region/%s/network/%s/subnet/%s/gateway" (ovh/resource_cloud_project_gateway.go:101) to create the Gateway. And there is no API to only create the Gateway without the subnet.

durandx avatar Mar 02 '23 12:03 durandx

Any update regarding this MR ? would be great to have a native interraction of OVH API for gateway in the provider

DrummyFloyd avatar Oct 18 '23 20:10 DrummyFloyd

Hi @rbeuque74 , can you have a look? thanks! :-)

scraly avatar Oct 18 '23 20:10 scraly

~any update regarding this ?~

i've made the part of the MR with test and doc update related to the gateway resource ( not the interface gateway)

https://github.com/ovh/terraform-provider-ovh/pull/571

DrummyFloyd avatar Mar 09 '24 17:03 DrummyFloyd

Closing this PR as it has been replaced by: https://github.com/ovh/terraform-provider-ovh/pull/697

amstuta avatar Jul 29 '24 07:07 amstuta