Live resize image with Terraform

Hi!

I’m playing with the Opennebula provider for Terraform and have a question about how to resize an existing image. In the documentation I can’t find how to resize an existing image, only how to create a new image. I have tried different things, but each time the existing image will be deleted first and then recreated instead of resizing the current image.

The image is in use by the virtual machine, so I had also played around with options described here[1]. Only this gives the same result, the image will be deleted.

Is it possible to perform a live disk resize via Terraform? And if so, how could I do this?

Thanks for helping!

[1] Terraform Registry

2 Likes

Hi @DeBuXer!

It’s related to the way the terraform handles existing parameters, I remember I had this problem a long time ago but managed to fixed by trimming down on config parameters. Can you share your existing resource?

In the end you should end up with something like this.

  disk {
    image_id = data.opennebula_template.template.disk[0].image_id
    size     = var.os_disk_size * 1024
    target   = "vda"
  }
4 Likes

Hi @TGM!

Thank you! This is exactly what I was looking for. I just had to add the size, then it worked for me.

  disk {
    image_id = opennebula_image.clone_image.id
    size     = 15 * 1024
    target   = "sda"
  }

Thanks again!

2 Likes