terraform-provider-ionoscloud icon indicating copy to clipboard operation
terraform-provider-ionoscloud copied to clipboard

unableto create empty volume

Open is2admin opened this issue 3 years ago • 18 comments
trafficstars

Description

im unable to create an empty volume - unlike in the dcd i have to name

'image_name', 'licence_type', or 'image_alias' must be set

i just want to create additional empty drives with hosts easy in dcd but with terraform that seems not possible

Expected behavior

create empty volume

Environment

Terraform version:

Terraform v1.3.1

Provider version:

version = "6.3.2"

OS:

ubuntu

Configuration Files

How to Reproduce

Error and Debug Output

is2admin avatar Oct 06 '22 11:10 is2admin

Terraform supports creating attached volumes. This is why it also requires server_id. Maybe you can try using ansible for this meanwhile? https://github.com/ionos-cloud/module-ansible/blob/master/docs/api/compute-engine/volume.md

cristiGuranIonos avatar Oct 07 '22 10:10 cristiGuranIonos

I know that and i am able to create a volume. server_id is no problem but i must name an image, but why ? Doesn't make any sense to add another volume with ubuntu on it - i want a volume thats without os that i can use for app storage/logs etc. With DCD this is an easy task - but it seems impossible with terraform. Thx for the tip with ansible module but this is not an option.

lachnerd avatar Oct 07 '22 12:10 lachnerd

You can try to set licence_type to "Unknown", see if that helps.

cristiGuranIonos avatar Oct 07 '22 13:10 cristiGuranIonos

Usually licence_type is required. But if if an image_name or image_alias is provided the licence_type is already configured at the image and will be used instead. In that case the licence_type can be omitted. Besides "UNKNOWN" you can also use "OTHER" as value.

jbuchhammer avatar Oct 07 '22 15:10 jbuchhammer

ok i tested adding a volume with

resource "ionoscloud_volume" "example" {
  datacenter_id           = var.datacenter_id
  server_id               = ionoscloud_server.host.id
  name                    = "Volume Example"
  availability_zone       = var.availability_zone
  size                    = "100"
  disk_type         = var.disk_type
  licence_type            = "OTHER"   
  ssh_key_path = [var.public_key_file]
  image_password        = random_string.root_password.result
}

Does not work (same with 'licence_type = "UNKNOWN"')

''' │ Error: an error occured while creating a volume: 500 Internal Server Error { │ "httpStatus" : 500, │ "messages" : [ { │ "errorCode" : "301", │ "message" : "Oops! Something went very wrong. Please contact the administrator" │ } ] │ } '''

lachnerd avatar Oct 10 '22 07:10 lachnerd

Hello, we will take a look and then will inform you when we'll have a solution.

gabriel-savu avatar Oct 11 '22 07:10 gabriel-savu

There was a backend maintenance and that might have cauised the 500 err response. Would it be possible to try again and let us know if it reproduces? Thanks!

cristiGuranIonos avatar Oct 12 '22 07:10 cristiGuranIonos

Hello, I managed to reproduce the behavior for the volume. We opened a issue too because it's an api error, but if you want to create a empty volume, you can remove the ssh_key_path for the moment. For me worked like this:

resource "ionoscloud_volume" "example" {
  datacenter_id           = ionoscloud_datacenter.example.id
  server_id               = ionoscloud_server.example.id
  name                    = "Volume Example"
  availability_zone       = "AUTO"
  size                    = "100"
  disk_type               = "HDD"
  licence_type            = "OTHER"   
}

We'll lelt you know when the pronlem with ssh_key_path will be solved and thank you for let us know.

gabriel-savu avatar Oct 26 '22 11:10 gabriel-savu

│ Error: an error occured while creating a volume: 422 Unprocessable Entity { │ "httpStatus" : 422, │ "messages" : [ { │ "errorCode" : "100", │ "message" : "[(root).properties.imagePassword] Attribute 'image' or 'imageAlias' must be set for password" │ } ] │ }

nope unfortunately also not working...

lachnerd avatar Nov 02 '22 15:11 lachnerd

hello, this is the error for the plan that I provided above? I am asking, because with that example I was not able to reproduce this error, but looking to the error, I think you have the user_data field set in terraform plan, which force you to provide either image or image_alias field.

gabriel-savu avatar Nov 03 '22 15:11 gabriel-savu

hello, this is the error for the plan that I provided above?

yap, correct

lachnerd avatar Nov 03 '22 15:11 lachnerd

but you have the user_data field set in terraform plan? Normally this field will trigger this error. If you want to use user_data field, you need to provide either a public image or image_alias. if not it will return an the api error from above

gabriel-savu avatar Nov 03 '22 16:11 gabriel-savu

negative, no "user_data" field set

  datacenter_id           = var.datacenter_id
  server_id               = ionoscloud_server.host.id
  name                    = "Volume Example"
  availability_zone       = var.availability_zone
  size                    = "33"
  disk_type         = var.disk_type
  licence_type            = "UNKNOWN"   
  #ssh_key_path = [var.public_key_file]
  #image_password        = random_string.root_password.result
}```

lachnerd avatar Nov 04 '22 06:11 lachnerd

can you please attach the server too to a message here be more easy to reproduce?

gabriel-savu avatar Nov 04 '22 09:11 gabriel-savu

server ressource

resource "ionoscloud_server" "host" {
    name                  = var.name
    datacenter_id         = var.datacenter_id
    cores                 = var.cpu_core
    ram                   = var.ram * 1024
    availability_zone     = var.availability_zone
    cpu_family            = var.cpu_family
    image_name            = var.image_name
    image_password        = random_string.root_password.result
    #Will be renamed to ssk_keys in the future, to allow users to set both the ssh key path or directly the ssh key
    ssh_key_path = [var.public_key_file]
    type                  = var.type
    volume {
        name              = "system"
        size              = var.disk_size
        disk_type         = var.disk_type
    }
    nic {
        lan               = var.datacenter_lan_id
        name              = "${var.name}-lan"
        dhcp              = true
        firewall_active   = var.firewall_active
        #default 'inbound'
        #firewall_type     = "BIDIRECTIONAL"
        #ips               = [ ionoscloud_ipblock.example.ips[0], ionoscloud_ipblock.example.ips[1] ]
        ips               = var.ip_adresses
  }

  lifecycle {
    #nic makes trouble on reapply otherwise
    ignore_changes = [availability_zone, nic]
  }
}

lachnerd avatar Nov 04 '22 09:11 lachnerd

Thank you, I'll try to reproduce and come with some updates

gabriel-savu avatar Nov 07 '22 09:11 gabriel-savu

I could't managed to reproduce the error with the tf plan that you provided, so here is a working example:

resource "ionoscloud_server" "host" {
    name                  = "Server Example"
    datacenter_id         = ionoscloud_datacenter.example.id
    cores                 = 1
    ram                   = 1024
    availability_zone     = "ZONE_1"
    cpu_family            = "AMD_OPTERON"
    image_name            = "ubuntu-22.04-server-cloudimg-amd64-20220902"
    image_password        = "aPassword"
    #Will be renamed to ssk_keys in the future, to allow users to set both the ssh key path or directly the ssh key
    ssh_key_path          = ["path/to/public/rsa/key"]    
    type                  = "ENTERPRISE"
    
    volume {
        name              = "system"
        size              = "100"
        disk_type         = "HDD"
    }
    nic {
         lan               = ionoscloud_lan.example.id
        name              = "system nic"
        dhcp              = true
        firewall_type     = "BIDIRECTIONAL"
        #default 'inbound'
        #firewall_type     = "BIDIRECTIONAL"
        ips               = [ ionoscloud_ipblock.example.ips[0], ionoscloud_ipblock.example.ips[1] ]
        #ips               = var.ip_adresses
  }

  lifecycle {
    #nic makes trouble on reapply otherwise
    ignore_changes = [availability_zone, nic]
  }
}

maybe there is a variable value which trigger this error, so if you want, you can provide the values for vars, except sensitive data, of course to try to use them and see if I can get 422 error.

gabriel-savu avatar Nov 10 '22 10:11 gabriel-savu

Hello, again, we found a case for the error, if you provide a licence_type for the volume resource, but the server does not have a image_name, then a 500 error will be displayed. We opened a ticket for this for another team and we will reply wen we'll have some updates.

gabriel-savu avatar Nov 14 '22 13:11 gabriel-savu