contabo / terraform-provider-contabo

Terraform Provider for Contabo Cloud-Services
MIT License
59 stars 7 forks source link

Instance creation API error 400 #1

Closed vsilent closed 2 years ago

vsilent commented 2 years ago

Hello, we are trying to create an instance at Contabo using terraform and we get an API error.

resource "contabo_instance" "servers"{
    product_id  = "V1"
    region      = "EU"
    period      = 1
}
resource "contabo_private_network" "inst_network" {
  name        = var.network_name
}
 Error: API error, status code: 400
│
│   with contabo_instance.servers,
│   on servers.tf line 2, in resource "contabo_instance" "servers":
│    2: resource "contabo_instance" "servers"{
│
│ API error, status code: 400, details: json: cannot unmarshal array into Go struct field ApiError.message of type string{"statusCode":400,"message":["productId must be
│ longer than or equal to 1 characters"]}

When we change product_id value from "V1" to "1" we get another error from API

resource "contabo_instance" "servers"{
    product_id  = "1"
    region      = "EU"
    image_id    = "66abf39a-ba8b-425e-a385-8eb347ceac10"
    period      = 1
}
resource "contabo_private_network" "inst_network" {
  name        = var.network_name
}
│ Error: API error, status code: 400
│
│   with contabo_instance.servers,
│   on servers.tf line 6, in resource "contabo_instance" "servers":
│    6: resource "contabo_instance" "servers"{
│
│ API error, status code: 400, details: Bad Request productId 66abf39a-ba8b-425e-a385-8eb347ceac10 is wrong

TF settings are configured according to the following : https://registry.terraform.io/providers/contabo/contabo/latest/docs/resources/contabo_instance#image_id https://github.com/contabo/terraform-provider-contabo/blob/main/examples/main.tf.example

Thanks !

vsilent commented 2 years ago

Same error happens if we use a default image_id from the docs

string
Default: “db1409d2-ed92-4f2f-978e-7b2fa4a1ec90”
ImageId to be used to setup the compute instance. Default is Ubuntu 20.04

Source: https://api.contabo.com/#tag/Instances/operation/createInstance

ngotzmann commented 2 years ago

Thank you for providing this issue! We had a small bug in the instance resource, it is fixed in version v0.1.11. You are now able to use the product_id as documented with V1 and the default image_id is now working.

If you want to add your freshly created instance to a private_network, you have to wait until the instance is installed, please use for the moment the time_sleep resource with around 1 minute to sleep. This is a known bug and will be fixed in the next versions.

If you find other bugs or have questions, please reach out to us. We are happy to support you and improve our terraform provider!