Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when creating a compute instance #190

Closed
wasadigi opened this issue Jul 6, 2022 · 8 comments
Closed

Error when creating a compute instance #190

wasadigi opened this issue Jul 6, 2022 · 8 comments

Comments

@wasadigi
Copy link

wasadigi commented Jul 6, 2022

I am trying to provision a compute instance, but when I terraform apply, I get the following error:

Error: Post "https://api-ch-gva-2.exoscale.com/v2/instance": invalid request: bad request

Here is my config. I am not sure if I should specify a endpoint, as I have seen some examples with, and others without.

terraform {
  required_providers {
    exoscale = {
      source  = "exoscale/exoscale"
      version = ">=0.38.0"
    }
  }
}

provider "exoscale" {
  key = "${var.exoscale_api_key}"
  secret = "${var.exoscale_api_secret}"
  // compute_endpoint = "https://api.exoscale.com/compute"
}

locals {
  zone = "ch-gva-2"
}

data "exoscale_compute_template" "ubuntu" {
  zone = local.zone
  name = "Linux Ubuntu 22.04 LTS 64-bit"
}

resource "exoscale_compute_instance" "testing"  {
  zone = local.zone
  name = "test_name"
  type = "standard.medium"
  template_id = data.exoscale_compute_template.ubuntu.id
  disk_size = 10
  ssh_key = "olivier"
}

Note that the template is resolved correctly. I looked at the doc and I didn't see any required field for which I am not providing a value.

  # exoscale_compute_instance.testing will be created
  + resource "exoscale_compute_instance" "testing" {
      + created_at          = (known after apply)
      + disk_size           = 10
      + id                  = (known after apply)
      + ipv6                = false
      + ipv6_address        = (known after apply)
      + name                = "test_name"
      + private_network_ids = (known after apply)
      + public_ip_address   = (known after apply)
      + ssh_key             = "olivier"
      + state               = (known after apply)
      + template_id         = "54d8e676-d46a-4559-87e7-e0feed79e770"
      + type                = "standard.medium"
      + zone                = "ch-gva-2"
    }
@wasadigi
Copy link
Author

wasadigi commented Jul 6, 2022

I tried the example from https://registry.terraform.io/providers/exoscale/exoscale/latest/docs/resources/compute_instance. In this case, it creates the security group and the private network, but fails on the instance. The error message is different:

Error: Post "https://api-ch-gva-2.exoscale.com/v2/instance": resource not found
locals {
  zone = "ch-gva-2"
}

data "exoscale_compute_template" "ubuntu" {
  zone = local.zone
  name = "Linux Ubuntu 20.04 LTS 64-bit"
}

resource "exoscale_security_group" "web" {
  name = "web"
}

data "exoscale_security_group" "default" {
  name = "default"
}

resource "exoscale_private_network" "example" {
  name = "privnet"
  zone = local.zone

  start_ip = "10.0.0.20"
  end_ip   = "10.0.0.253"
  netmask  = "255.255.255.0"
}

resource "exoscale_compute_instance" "example" {
  zone               = local.zone
  name               = "webserver"
  type               = "standard.medium"
  template_id        = data.exoscale_compute_template.ubuntu.id
  disk_size          = 10
  security_group_ids = [
    data.exoscale_security_group.default.id, 
    exoscale_security_group.web.id,
  ]
  ssh_key            = "my-key"
  user_data          = <<EOF
#cloud-config
manage_etc_hosts: localhost
EOF

  network_interface {
    network_id = exoscale_private_network.example.id
    ip_address = "10.0.0.20"
  }
}

@wasadigi
Copy link
Author

wasadigi commented Jul 6, 2022

I thought that the missing security_group_ids might be the cause (although it is not described as required). So I updated my spec... but without success. Still the same bad request error. I have tried to trace terraform, but I don't see communication between the provider and the api.

data "exoscale_security_group" "default" {
  name = "default"
}

resource "exoscale_compute_instance" "testing"  {
  zone = local.zone
  name = "test_name"
  type = "standard.medium"
  template_id = data.exoscale_compute_template.ubuntu.id
  security_group_ids = [
    data.exoscale_security_group.default.id, 
  ]
  disk_size = 10
  ssh_key = "olivier"
}

@wasadigi
Copy link
Author

wasadigi commented Jul 6, 2022

Hum... using type = "gpu.small" gives me another error: "Post "https://api-ch-gva-2.exoscale.com/v2/instance": invalid request: This instance type is not allowed for your account".

I had the idea to try this, because I was looking for the list of accepted values for type. Is it available anywhere?

@wasadigi
Copy link
Author

wasadigi commented Jul 6, 2022

exo compute instance-type list seems to be what I was looking for... but using these values does not fix my original problem.

$ exo compute instance-type list
┼──────────────────────────────────────┼──────────┼─────────────┼
│                  ID                  │  FAMILY  │    SIZE     │
┼──────────────────────────────────────┼──────────┼─────────────┼
│ 71004023-bb72-4a97-b1e9-bc66dfce9470 │ standard │ micro       │
│ b6cd1ff5-3a2f-4e9d-a4d1-8988c1191fe8 │ standard │ tiny        │
│ 21624abb-764e-4def-81d7-9fc54b5957fb │ standard │ small       │
│ b6e9d1e8-89fc-4db3-aaa4-9b4c5b1d0844 │ standard │ medium      │
│ c6f99499-7f59-4138-9427-a09db13af2bc │ standard │ large       │
│ 350dc5ea-fe6d-42ba-b6c0-efb8b75617ad │ standard │ extra-large │
│ a216b0d1-370f-4e21-a0eb-3dfc6302b564 │ standard │ huge        │
│ c0d3fb5d-6fdb-4a63-9361-3e5cfa8b36d0 │ standard │ mega        │
│ 74bfaf4e-7d67-4adf-9322-12b9a36e84f7 │ standard │ titan       │
│ 07246b95-bbe4-498f-92a3-ce5be4d38342 │ gpu      │ small       │
│ dee65287-12cf-4e36-b635-32dbc9a2e909 │ gpu      │ huge        │
│ 011a5079-845d-467b-a660-8685dad1cb67 │ standard │ jumbo       │
│ 847b3a94-659f-445e-ba7e-d02f89355e1b │ gpu      │ medium      │
│ 1ee13a8a-38ec-4858-a7c5-82f707810ea3 │ gpu      │ large       │
│ f17df7cf-aced-4314-8709-4a0041408fdf │ storage  │ extra-large │
│ ebc4743c-9c7b-490d-8958-17a89561d9a3 │ storage  │ huge        │
│ a3bd08e2-bcdd-45b3-b6de-507d15056dae │ storage  │ mega        │
│ 964fd954-40ca-420f-871d-0aa7c5fac230 │ storage  │ titan       │
│ dec751cc-6e3b-4ac1-8a14-fdfdf46fd1f7 │ storage  │ jumbo       │
│ d141049f-71a3-4b1a-9016-3df0ac9a8cc9 │ gpu2     │ small       │
│ 98d53f21-06e2-4e38-8da7-d5e9ae570c83 │ gpu2     │ medium      │
│ 98981aba-d258-485b-89b2-52708768e88d │ gpu2     │ large       │
│ e61976b7-3527-4898-9b2c-382d7eeb49a0 │ gpu2     │ huge        │
│ 221d39c3-b2b9-4014-b32b-5d262f684eff │ cpu      │ extra-large │
│ 68c91810-55ed-4685-9771-00d9adf7b7c0 │ cpu      │ huge        │
│ c2f204df-29fc-4c20-b5c4-bdb21282cecc │ cpu      │ mega        │
│ e1ae0088-27fd-4185-a057-075ea0b0aa02 │ cpu      │ titan       │
│ dd6abc94-337f-4732-baff-ed745f8bd4f5 │ memory   │ extra-large │
│ efbf55db-01c9-4c73-973f-cecc4d26dcde │ memory   │ huge        │
│ 306eeeae-38e9-4add-897b-4eff0b019a6d │ memory   │ mega        │
│ 68a4780f-cc91-4df6-a735-d679318289bc │ memory   │ titan       │
│ 8a52e80d-b1d0-4efb-8059-a931fa33c5a1 │ standard │ colossus    │
│ 1552f778-726f-477f-85d2-92c3ca42e499 │ gpu3     │ small       │
│ 30d08069-5101-4029-a847-c5be5d916eb0 │ gpu3     │ medium      │
│ 2bf11dfd-5915-496d-bc0d-9f836f2fe7be │ gpu3     │ large       │
│ 5a426186-9f55-43a1-8e81-6736b2e4a73f │ gpu3     │ huge        │
┼──────────────────────────────────────┼──────────┼─────────────┼

@wasadigi
Copy link
Author

wasadigi commented Jul 6, 2022

Looks like the _ underscore in the name was the culprit...

@wasadigi
Copy link
Author

wasadigi commented Jul 6, 2022

Indeed:

image

@wasadigi
Copy link
Author

wasadigi commented Jul 6, 2022

The issue is solved. I keep it open, to ask one last question: to debug this type of problem, is there any way to get some trace to understand why the server is unhappy?

@kobajagi
Copy link
Contributor

kobajagi commented Jul 6, 2022

Hey @wasadigi , you can try running terraform commands with TF_LOG=DEBUG, that will also print full exoscale API responses.

@wasadigi wasadigi closed this as completed Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants