Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions ovh/pci-private-subnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ Create a subnet in OVH PCI (openstack)
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.3 |
| <a name="requirement_openstack"></a> [openstack](#requirement\_openstack) | ~> 1.49.0 |
| <a name="requirement_ovh"></a> [ovh](#requirement\_ovh) | ~> 0.24.0 |
| <a name="requirement_ovh"></a> [ovh](#requirement\_ovh) | ~> 2.1 |
| <a name="requirement_time"></a> [time](#requirement\_time) | ~> 0.9.1 |

## Providers

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

## Modules
Expand All @@ -26,18 +25,23 @@ No modules.

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

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_cloud_project_id"></a> [cloud\_project\_id](#input\_cloud\_project\_id) | OVH service name | `string` | n/a | yes |
| <a name="input_customer"></a> [customer](#input\_customer) | Customer applied to this instance | `string` | `""` | no |
| <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 |
| <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 |
| <a name="input_dhcp"></a> [dhcp](#input\_dhcp) | Enable DHCP | `string` | `true` | no |
| <a name="input_end"></a> [end](#input\_end) | Last ip for this region | `string` | n/a | yes |
| <a name="input_name"></a> [name](#input\_name) | Name applied to this instance | `string` | `""` | no |
| <a name="input_network_id"></a> [network\_id](#input\_network\_id) | OVH vrack network id | `string` | n/a | yes |
| <a name="input_network"></a> [network](#input\_network) | Global network in CIDR format | `string` | n/a | yes |
| <a name="input_network_id"></a> [network\_id](#input\_network\_id) | ID of the private network | `string` | n/a | yes |
| <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 |
| <a name="input_region"></a> [region](#input\_region) | array of OVH pci regions where the subnet will exists | `string` | n/a | yes |
| <a name="input_start"></a> [start](#input\_start) | First ip for this region | `string` | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | Tags applied to this instance | `map(string)` | `{}` | no |

## Outputs
Expand Down
6 changes: 3 additions & 3 deletions ovh/pci-private-subnet/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
output "id" {
value = openstack_networking_subnet_v2.subnet.id
value = ovh_cloud_project_network_private_subnet.subnet.id
}

output "network_id" {
value = openstack_networking_subnet_v2.subnet.network_id
value = ovh_cloud_project_network_private_subnet.subnet.network_id
}

output "gateway_ip" {
value = openstack_networking_subnet_v2.subnet.gateway_ip
value = ovh_cloud_project_network_private_subnet.subnet.gateway_ip
}
22 changes: 9 additions & 13 deletions ovh/pci-private-subnet/private-subnet.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
resource "openstack_networking_subnet_v2" "subnet" {
name = var.name
network_id = var.network_id
cidr = var.ip.network
ip_version = 4

dns_nameservers = var.dns_nameservers

allocation_pool {
start = var.ip.start
end = var.ip.end
}
tags = [for k, v in local.interpolated_tags : "${k}=${v}"]
resource "ovh_cloud_project_network_private_subnet" "subnet" {
service_name = var.cloud_project_id
network_id = var.network_id
region = var.region
network = var.network
start = var.start
end = var.end
dhcp = var.dhcp
no_gateway = var.no_gateway
}
6 changes: 1 addition & 5 deletions ovh/pci-private-subnet/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ terraform {
}
ovh = {
source = "ovh/ovh"
version = "~> 0.24.0"
}
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.49.0"
version = "~> 2.1"
}
}
}
47 changes: 34 additions & 13 deletions ovh/pci-private-subnet/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,44 @@ variable "tags" {
}

# bellow are specific modules variables
variable "cloud_project_id" {
description = "OVH service name"
type = string
}

variable "network_id" {
type = string
description = "OVH vrack network id"
description = "ID of the private network"
}

variable "ip" {
type = map(any)
description = "map of subnet ip elements {start, end, netwok}"
default = {
start = "10.0.0.1"
end = "10.0.254.254"
network = "10.0.0.0/16"
}
variable "region" {
type = string
description = "array of OVH pci regions where the subnet will exists"
}

variable "dns_nameservers" {
type = list(string)
description = "list of dns servers that will be send by dhcp on this subnet"
default = ["8.8.8.8", "8.8.4.4"]
variable "network" {
type = string
description = "Global network in CIDR format"
}

variable "start" {
type = string
description = "First ip for this region"
}

variable "end" {
type = string
description = "Last ip for this region"
}

variable "dhcp" {
type = string
description = "Enable DHCP"
default = true
}

variable "no_gateway" {
type = string
description = "Set to true if you don't want to set a default gateway IP"
default = false
}
Loading