ionos-cloud/terraform-provider-ionoscloud

Getting 422 errors with simple example - but cannot be diagnosed

Ntr0 opened this issue · 1 comments

Ntr0 commented

log.txt

Description

I ran into 422 errors coming from the cloud api. This is my tf file

terraform {
  required_version = ">= 0.15.0"

  required_providers {
    ionoscloud = {
      source = "ionos-cloud/ionoscloud"
      version = ">=5.1.1"
    }
  }

}
variable "IONOS_USERNAME" {
  type = string
}
variable "IONOS_PASSWORD" {
  type = string
  sensitive = true
}


provider "ionoscloud" {
  username = var.IONOS_USERNAME
  password = var.IONOS_PASSWORD
}

resource "ionoscloud_datacenter" "test-csi-terratest" {
  name = "terratest"
  location = "de/txl"
  description = "created by ntr0"
}

resource "ionoscloud_lan" "public" {
  name = "public"
  public = true
  datacenter_id = ionoscloud_datacenter.test-csi-terratest.id
}

resource "ionoscloud_server" "csi-test-srv" {
  name = "testsrv"
  datacenter_id = ionoscloud_datacenter.test-csi-terratest.id
  cores = 1
  ram = 1024
  image_password = "test-csi-please"
  image_name = "ubuntu:latest"
  ssh_key_path = var.ssh_key_path
  volume {
    name = "testsrv-vol"
    size = 10
    disk_type = "SSD"
  }
  nic {
    lan = ionoscloud_lan.public.id
    dhcp = true
  }
}

Expected behavior

Server is created

Environment

Terraform version:

$ terraform version                                                                                                                                                          
Terraform v0.15.4
on linux_amd64
+ provider registry.terraform.io/ionos-cloud/ionoscloud v5.1.1

OS:

Fedora release 33 (Thirty Three)

Configuration Files

How to Reproduce

Apply given example

Error and Debug Output

See attachment, but in short:

╷
│ Error: Error creating server: (422 Unprocessable Entity)
│ 
│   with ionoscloud_server.csi-test-srv,
│   on main.tf line 38, in resource "ionoscloud_server" "csi-test-srv":
│   38: resource "ionoscloud_server" "csi-test-srv" {
│ 
╵

Additional Notes

If I had found any mean to debug the actual http requests / responses, I would have been able to point to the actual problem. If there is, it would be great to have that hint available, at least in the bug template maybe.

References

@Ntr0 regarding means of debugging the actual response from the request, please check version v5.2.1 since it contains and enhancement on this topic, providing also the API response in the error.

As per your error, the problem is with the format of the password, the detailed response being:

│ Error: error creating server: (422 Unprocessable Entity: {
│   "httpStatus" : 422,
│   "messages" : [ {
│     "errorCode" : "100",
│     "message" : "[(root).entities.volumes.items.[0].properties.imagePassword] Password syntax error. Password invalid, valid characters are: a-zA-Z0-9. Length between 8 and 50."
│   } ]
│ }
│ )