Public Cloud OVHcloud - Création d'un réseau privé avec Terraform
BMPCreated with Sketch.BMPZIPCreated with Sketch.ZIPXLSCreated with Sketch.XLSTXTCreated with Sketch.TXTPPTCreated with Sketch.PPTPNGCreated with Sketch.PNGPDFCreated with Sketch.PDFJPGCreated with Sketch.JPGGIFCreated with Sketch.GIFDOCCreated with Sketch.DOC Error Created with Sketch.
Frage

Création d'un réseau privé avec Terraform

Von
NelsonA
Erstellungsdatum 2022-08-10 07:33:54 (edited on 2024-09-04 13:15:40) in Public Cloud OVHcloud

Bonjour,

J'essaie de créer un réseau privé via terraform et d'y ajouter une instance. Le réseau et le sous-réseau ce créent correctement mais j'ai une erreur au moment de la création de l'instance.

Voilà mon fichier de configuration:

```
# main.tf

# Version terraform: Terraform v1.0.11

terraform {
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = "1.45.0"
}

ovh = {
source = "ovh/ovh"
version = "0.18.1"
}
}
}

provider "openstack" {
auth_url = "https://auth.cloud.ovh.net/v3/"
domain_name = "default" # Always "default" for OVHcloud
alias = "ovh"
tenant_id = "..."
}

provider "ovh" {
alias = "ovh"
endpoint = "ovh-eu"
application_key = "..."
application_secret = "..."
consumer_key = "..."
}

resource "ovh_cloud_project_network_private" "hadb-pn" {
provider = ovh.ovh
service_name = "..."
name = "pn-hadb"
regions = var.ovh_regions
vlan_id = 168
}

resource "ovh_cloud_project_network_private_subnet" "hadb-subnet" {
provider = ovh.ovh
service_name = "..."
network_id = ovh_cloud_project_network_private.hadb-pn.id
start = "10.42.0.1"
end = "10.42.0.100"
network = "10.42.0.0/24"
region = element(var.ovh_regions, 0)
no_gateway = true
}

module "ovh" {
source = "./modules/ovh"

providers = {
openstack = openstack.ovh
}

count = length(var.ovh_regions)

database_volume_size = var.database_volume_size
instance_type = "s1-2"
private_network_ip = "10.42.0.${count.index + 1}"
private_network_name = ovh_cloud_project_network_private.hadb-pn.name
region = element(var.ovh_regions, count.index)
ssh_key_path = var.ssh_key_path
ssh_key_name = var.ssh_key_name
subnet_id = ovh_cloud_project_network_private_subnet.hadb-subnet.id
}

# modules/ovh/main.tf

resource "openstack_compute_instance_v2" "ha-db" {
name = "ha-db"
image_name = "Ubuntu 18.04"
flavor_name = var.instance_type
key_pair = openstack_compute_keypair_v2.keypair.name
security_groups = [openstack_networking_secgroup_v2.ha-db_sg.name]
region = var.region

network {
name = "Ext-Net"
}

network {
name = var.private_network_name
fixed_ip_v4 = var.private_network_ip
}
}
```

Voilà l'erreur:

```
│ Error: Error creating OpenStack server: Bad request with: [POST https://compute.de1.cloud.ovh.net/v2.1/.../servers], error message: {"badRequest": {"code": 400, "message": "Network
04f51f23-1be8-409b-9c85-9e0c02091135 requires a subnet in order to boot instances on."}}

│ with module.ovh[1].openstack_compute_instance_v2.ha-db,
│ on modules/ovh/main.tf line 123, in resource "openstack_compute_instance_v2" "ha-db":
│ 123: resource "openstack_compute_instance_v2" "ha-db" {



│ Error: Error waiting for instance (e6b46a27-e3e5-4a72-817f-33ca5be39339) to become ready: unexpected state 'ERROR', wanted target 'ACTIVE'. last error: %!s()

│ with module.ovh[0].openstack_compute_instance_v2.ha-db,
│ on modules/ovh/main.tf line 123, in resource "openstack_compute_instance_v2" "ha-db":
│ 123: resource "openstack_compute_instance_v2" "ha-db" {

```