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

Vrack: Network requires a subnet in order to boot instances on

Open Spounge opened this issue 2 years ago • 0 comments

Hello,

I'm trying to use a private network in my project but I get an error at the creation of my instances telling me that network doesn't have a subnet.

Terraform Version

Terraform v1.0.11

Affected Resource(s)

  • ovh_cloud_project_network_private
  • ovh_cloud_project_network_private_subnet
  • openstack_compute_instance_v2

Terraform Configuration Files

# main.tf

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    
  }    
}

Error Output

After applying.

│ 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(<nil>)
│                                                                                                        
│   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" {                                               
│  

Expected Behavior

Create two instances in two datacenters connected by a private network.

Spounge avatar Jul 22 '22 14:07 Spounge