civo / terraform-provider-civo

Terraform Civo provider
https://www.civo.com
Mozilla Public License 2.0
71 stars 56 forks source link

[BUG] Unable to create new network. Resource quota maxed out. #256

Closed furstenbergs closed 3 months ago

furstenbergs commented 4 months ago

Description

Hi,

I recently starting testing Civo as an alternative cloud provider. I prefer to use Terraform to provision all my infrastructure. For a start, I'm just trying to create a new network. Here is my Terrafrom configuration:

terraform {
  required_providers {
    civo = {
      source = "civo/civo"
      version = "1.0.46"
    }
  }
}

provider "civo" {
  token = var.civo_token
  region = "LON1"
}

resource "civo_network" "test_network" {
    label = "test_network"
    cidr_v4 = "172.20.0.0/16"
    nameservers_v4 = ["1.1.1.1", "8.8.8.8"]
}

However, the network fails to create and terrafrom is retrying, but seems with each retry, it is increasing the usage.

terraform apply --auto-approve

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:

  # civo_network.test_network will be created
  + resource "civo_network" "test_network" {
      + cidr_v4        = "172.20.0.0/16"
      + default        = (known after apply)
      + id             = (known after apply)
      + label          = "test_network"
      + name           = (known after apply)
      + nameservers_v4 = [
          + "1.1.1.1",
          + "8.8.8.8",
        ]
      + region         = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.
civo_network.test_network: Creating...
civo_network.test_network: Still creating... [10s elapsed]
civo_network.test_network: Still creating... [20s elapsed]
civo_network.test_network: Still creating... [30s elapsed]
civo_network.test_network: Still creating... [40s elapsed]
civo_network.test_network: Still creating... [50s elapsed]
civo_network.test_network: Still creating... [1m0s elapsed]
civo_network.test_network: Still creating... [1m10s elapsed]
civo_network.test_network: Still creating... [1m20s elapsed]
civo_network.test_network: Still creating... [1m30s elapsed]
civo_network.test_network: Still creating... [1m40s elapsed]
civo_network.test_network: Still creating... [1m50s elapsed]
civo_network.test_network: Still creating... [2m0s elapsed]
╷
│ Error: [ERR] failed to create a new network after multiple attempts: timeout reached
│
│   with civo_network.test_network,
│   on network.tf line 1, in resource "civo_network" "test_network":
│    1: resource "civo_network" "test_network" {
│
╵

Screenshots

Before Terraform run:

Screenshot 2024-07-16 at 10 07 26

After Terraform run, and no resources created:

Screenshot 2024-07-15 at 15 44 36

After a few minuets the usages drops back down to "2".

Additional information

No response

uzaxirr commented 4 months ago

Hey @furstenbergs Can you do the following.

Via UI check if resource has been provisioned or not. if yes delete it to free up your quota. do a export TF_LOG=DEBUG in your terminal. and then do a terraform apply. You should be able to see a detailed reason now.

furstenbergs commented 4 months ago

Hi @uzaxirr Thanks for the quick response

No resources have been provisioned.

Running again with export TF_LOG=DEBUG shows the reason for failure is because my CIDR is to large.

2024-07-16T10:20:26.110+0200 [INFO]  provider.terraform-provider-civo_v1.0.46: 2024/07/16 10:20:26 [INFO] Retrying after error: Error: Unknown error response - status: 400 Bad Request, code: 400, reason: {"code":"invalid_v4_cidr_provided","reason":"The provided v4 CIDR must be a valid CIDR with a subnet mask comprehended between /22 and /28"}: timestamp="2024-07-16T10:20:26.109+0200"

This is my mistake as I assumed I can create a "/16" network and was not aware off the limitation.

However, perhaps this is a point of improvement. IE, if terrafrom is not able to apply because it is not a supported configuration, please respond with the error and stop.

uzaxirr commented 4 months ago

Thankss for bringing this into light @furstenbergs I'll you will surely see a fix for this in next release.