vultr / terraform-provider-vultr

Terraform Vultr provider
https://www.terraform.io/docs/providers/vultr/
Mozilla Public License 2.0
191 stars 65 forks source link

[BUG] - invalid plan when attempting to deploy bare metal-- can only do vpc #377

Open Sophrinix opened 1 year ago

Sophrinix commented 1 year ago

When I attempt to deploy a bare metal instance I get the following error

 Error: error creating server: {"error":"Invalid plan chosen.","status":400}
│ 
│   with vultr_instance.k8s-node[0],
│   on main.tf line 88, in resource "vultr_instance" "k8s-node":
│   88: resource "vultr_instance" "k8s-node" {

I have verified with

 curl "https://api.vultr.com/v2/plans-metal" \                    
  -X GET \
  -H "Authorization: Bearer ${VULTR_API}" | jq '.'

that I am in fact selecting a valid plan.

What i think is happening is somewhere in this provider code ,

   curl "https://api.vultr.com/v2/plans" \   
  -X GET \
  -H "Authorization: Bearer ${VULTR_API}" | jq '.'

is being used rather than both /v2/plans and /v2/plans-metal

if that is the case, where in the code is it calling /plans?

optik-aper commented 1 year ago

@Sophrinix What's the plan you're using? It's possible there's something funky on the platform.

Sophrinix commented 1 year ago

i have used several plan options. I tried (which is also valid and in your unit tests) "vbm-4c-32gb"

but i want vbm-24c-256gb-amd

optik-aper commented 1 year ago

I was able to provision that plan in the region ewr so I think it's working. Are you using a plan in a region where it doesn't exist? You can find the regions in the JSON output from that plans-metal call:

# update region code as relevant
curl "https://api.vultr.com/v2/plans-metal" -X GET --silent | jq '.plans_metal | map(select(.locations[] | contains("ewr"))) | .[] | .id'

"vbm-6c-32gb"
"vbm-24c-256gb-amd"
"vbm-8c-132gb-v2"
""
optik-aper commented 1 year ago
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:

  # vultr_bare_metal_server.bm1 will be created
  + resource "vultr_bare_metal_server" "bm1" {
      + app_id           = (known after apply)
      + cpu_count        = (known after apply)
      + date_created     = (known after apply)
      + default_password = (sensitive value)
      + disk             = (known after apply)
      + gateway_v4       = (known after apply)
      + id               = (known after apply)
      + image_id         = (known after apply)
      + label            = "tf-plan-test"
      + mac_address      = (known after apply)
      + main_ip          = (known after apply)
      + netmask_v4       = (known after apply)
      + os               = (known after apply)
      + os_id            = 1946
      + plan             = "vbm-24c-256gb-amd"
      + ram              = (known after apply)
      + region           = "ewr"
      + reserved_ipv4    = (known after apply)
      + status           = (known after apply)
      + tags             = [
          + "tf",
        ]
      + user_data        = (known after apply)
      + v6_main_ip       = (known after apply)
      + v6_network       = (known after apply)
      + v6_network_size  = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

vultr_bare_metal_server.bm1: Creating...
vultr_bare_metal_server.bm1: Still creating... [10s elapsed]
vultr_bare_metal_server.bm1: Still creating... [20s elapsed]
vultr_bare_metal_server.bm1: Still creating... [30s elapsed]
vultr_bare_metal_server.bm1: Still creating... [40s elapsed]
vultr_bare_metal_server.bm1: Still creating... [50s elapsed]
vultr_bare_metal_server.bm1: Still creating... [1m0s elapsed]

...

vultr_bare_metal_server.bm1: Still creating... [9m50s elapsed]
vultr_bare_metal_server.bm1: Still creating... [10m0s elapsed]
vultr_bare_metal_server.bm1: Still creating... [10m10s elapsed]
vultr_bare_metal_server.bm1: Still creating... [10m20s elapsed]
vultr_bare_metal_server.bm1: Still creating... [10m30s elapsed]
vultr_bare_metal_server.bm1: Still creating... [10m40s elapsed]
vultr_bare_metal_server.bm1: Still creating... [10m50s elapsed]
vultr_bare_metal_server.bm1: Still creating... [11m0s elapsed]
vultr_bare_metal_server.bm1: Creation complete after 11m10s [id=daa1264b-7ac2-4d24-8a8c-6154a4f51143]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.