Skip to content

Commit 406e585

Browse files
committed
feat: switch to ovh provider for private subnet
1 parent 16b0f12 commit 406e585

File tree

5 files changed

+58
-41
lines changed

5 files changed

+58
-41
lines changed

ovh/pci-private-subnet/README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ Create a subnet in OVH PCI (openstack)
77
| Name | Version |
88
|------|---------|
99
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.3 |
10-
| <a name="requirement_openstack"></a> [openstack](#requirement\_openstack) | ~> 1.49.0 |
11-
| <a name="requirement_ovh"></a> [ovh](#requirement\_ovh) | ~> 0.24.0 |
10+
| <a name="requirement_ovh"></a> [ovh](#requirement\_ovh) | ~> 2.1 |
1211
| <a name="requirement_time"></a> [time](#requirement\_time) | ~> 0.9.1 |
1312

1413
## Providers
1514

1615
| Name | Version |
1716
|------|---------|
18-
| <a name="provider_openstack"></a> [openstack](#provider\_openstack) | ~> 1.49.0 |
17+
| <a name="provider_ovh"></a> [ovh](#provider\_ovh) | ~> 2.1 |
1918
| <a name="provider_time"></a> [time](#provider\_time) | ~> 0.9.1 |
2019

2120
## Modules
@@ -26,18 +25,23 @@ No modules.
2625

2726
| Name | Type |
2827
|------|------|
29-
| [openstack_networking_subnet_v2.subnet](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/networking_subnet_v2) | resource |
28+
| [ovh_cloud_project_network_private_subnet.subnet](https://registry.terraform.io/providers/ovh/ovh/latest/docs/resources/cloud_project_network_private_subnet) | resource |
3029
| [time_static.last_update](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/static) | resource |
3130

3231
## Inputs
3332

3433
| Name | Description | Type | Default | Required |
3534
|------|-------------|------|---------|:--------:|
35+
| <a name="input_cloud_project_id"></a> [cloud\_project\_id](#input\_cloud\_project\_id) | OVH service name | `string` | n/a | yes |
3636
| <a name="input_customer"></a> [customer](#input\_customer) | Customer applied to this instance | `string` | `""` | no |
37-
| <a name="input_dns_nameservers"></a> [dns\_nameservers](#input\_dns\_nameservers) | list of dns servers that will be send by dhcp on this subnet | `list(string)` | <pre>[<br> "8.8.8.8",<br> "8.8.4.4"<br>]</pre> | no |
38-
| <a name="input_ip"></a> [ip](#input\_ip) | map of subnet ip elements {start, end, netwok} | `map(any)` | <pre>{<br> "end": "10.0.254.254",<br> "network": "10.0.0.0/16",<br> "start": "10.0.0.1"<br>}</pre> | no |
37+
| <a name="input_dhcp"></a> [dhcp](#input\_dhcp) | Enable DHCP | `string` | `true` | no |
38+
| <a name="input_end"></a> [end](#input\_end) | Last ip for this region | `string` | n/a | yes |
3939
| <a name="input_name"></a> [name](#input\_name) | Name applied to this instance | `string` | `""` | no |
40-
| <a name="input_network_id"></a> [network\_id](#input\_network\_id) | OVH vrack network id | `string` | n/a | yes |
40+
| <a name="input_network"></a> [network](#input\_network) | Global network in CIDR format | `string` | n/a | yes |
41+
| <a name="input_network_id"></a> [network\_id](#input\_network\_id) | ID of the private network | `string` | n/a | yes |
42+
| <a name="input_no_gateway"></a> [no\_gateway](#input\_no\_gateway) | Set to true if you don't want to set a default gateway IP | `string` | `false` | no |
43+
| <a name="input_region"></a> [region](#input\_region) | array of OVH pci regions where the subnet will exists | `string` | n/a | yes |
44+
| <a name="input_start"></a> [start](#input\_start) | First ip for this region | `string` | n/a | yes |
4145
| <a name="input_tags"></a> [tags](#input\_tags) | Tags applied to this instance | `map(string)` | `{}` | no |
4246

4347
## Outputs

ovh/pci-private-subnet/outputs.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
output "id" {
2-
value = openstack_networking_subnet_v2.subnet.id
2+
value = ovh_cloud_project_network_private_subnet.subnet.id
33
}
44

55
output "network_id" {
6-
value = openstack_networking_subnet_v2.subnet.network_id
6+
value = ovh_cloud_project_network_private_subnet.subnet.network_id
77
}
88

99
output "gateway_ip" {
10-
value = openstack_networking_subnet_v2.subnet.gateway_ip
10+
value = ovh_cloud_project_network_private_subnet.subnet.gateway_ip
1111
}
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
resource "openstack_networking_subnet_v2" "subnet" {
2-
name = var.name
3-
network_id = var.network_id
4-
cidr = var.ip.network
5-
ip_version = 4
6-
7-
dns_nameservers = var.dns_nameservers
8-
9-
allocation_pool {
10-
start = var.ip.start
11-
end = var.ip.end
12-
}
13-
tags = [for k, v in local.interpolated_tags : "${k}=${v}"]
1+
resource "ovh_cloud_project_network_private_subnet" "subnet" {
2+
service_name = var.cloud_project_id
3+
network_id = var.network_id
4+
region = var.region
5+
network = var.network
6+
start = var.start
7+
end = var.end
8+
dhcp = var.dhcp
9+
no_gateway = var.no_gateway
1410
}

ovh/pci-private-subnet/providers.tf

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ terraform {
77
}
88
ovh = {
99
source = "ovh/ovh"
10-
version = "~> 0.24.0"
11-
}
12-
openstack = {
13-
source = "terraform-provider-openstack/openstack"
14-
version = "~> 1.49.0"
10+
version = "~> 2.1"
1511
}
1612
}
1713
}

ovh/pci-private-subnet/variables.tf

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,44 @@ variable "tags" {
1818
}
1919

2020
# bellow are specific modules variables
21+
variable "cloud_project_id" {
22+
description = "OVH service name"
23+
type = string
24+
}
25+
2126
variable "network_id" {
2227
type = string
23-
description = "OVH vrack network id"
28+
description = "ID of the private network"
2429
}
2530

26-
variable "ip" {
27-
type = map(any)
28-
description = "map of subnet ip elements {start, end, netwok}"
29-
default = {
30-
start = "10.0.0.1"
31-
end = "10.0.254.254"
32-
network = "10.0.0.0/16"
33-
}
31+
variable "region" {
32+
type = string
33+
description = "array of OVH pci regions where the subnet will exists"
3434
}
3535

36-
variable "dns_nameservers" {
37-
type = list(string)
38-
description = "list of dns servers that will be send by dhcp on this subnet"
39-
default = ["8.8.8.8", "8.8.4.4"]
36+
variable "network" {
37+
type = string
38+
description = "Global network in CIDR format"
39+
}
40+
41+
variable "start" {
42+
type = string
43+
description = "First ip for this region"
44+
}
45+
46+
variable "end" {
47+
type = string
48+
description = "Last ip for this region"
49+
}
50+
51+
variable "dhcp" {
52+
type = string
53+
description = "Enable DHCP"
54+
default = true
55+
}
56+
57+
variable "no_gateway" {
58+
type = string
59+
description = "Set to true if you don't want to set a default gateway IP"
60+
default = false
4061
}

0 commit comments

Comments
 (0)