ovh / terraform-provider-ovh

Terraform OVH provider
https://registry.terraform.io/providers/ovh/ovh/latest/docs
Mozilla Public License 2.0
183 stars 135 forks source link

[BUG] Can't attach volume using openstack_compute_volume_attach_v2 resource to openstack_compute_instance_v2 #453

Closed yakzazazord closed 1 year ago

yakzazazord commented 1 year ago

Describe the bug

Hi, it seems I can't attach a openstack_blockstorage_volume_v2 resource to a compute_instance using the _openstack_compute_volume_attachv2 resource.

Terraform Version

1.5.5

OVH Terraform Provider Version

provider.terraform-provider-ovh_v0.32.0 provider.terraform-provider-openstack_v1.42

Affected Resource(s)

Please list the resources as a list, for example:

Terraform Configuration Files

# Creating an SSH key pair resource
resource "openstack_compute_keypair_v2" "test_keypair" {
  provider   = openstack.ovh # Provider name declared in provider.tf
  name       = "test_keypair" # Name of the SSH key to use for creation
  public_key = file(var.ssh_key_yakzazazord) # Path to your previously generated SSH key
  region      = var.myregion
}

# Creating the instance
resource "openstack_compute_instance_v2" "test_terraform_instance" {
  name        = "terraform_instance" # Instance name
  provider    = openstack.ovh  # Provider name
  /* image_id    = var.image_id # Image name */
  image_name  = var.image_name
  flavor_name = var.flavor_name # Instance type name
  region      = var.myregion
   # Name of openstack_compute_keypair_v2 resource named keypair_test
  key_pair    = openstack_compute_keypair_v2.test_keypair.name 
  network {
    name      = var.default_network # Adds the network component to reach your instance
  }
  depends_on = [openstack_compute_keypair_v2.test_keypair]
}

# Create a resource for storage
resource "openstack_blockstorage_volume_v2" "volume_to_add" {
  name = "simple_volume" # Volume name
  size = 10 # Volume size in GB
  provider = openstack.ovh # Provider name
}

# Attach the volume created previously to the instance
resource "openstack_compute_volume_attach_v2" "attached" {
  # ID of openstack_compute_instance_v2 resource named test_terraform_instance
  instance_id = openstack_compute_instance_v2.test_terraform_instance.id
  # ID of openstack_blockstorage_volume_v2 resource named volume_to_add
  volume_id = openstack_blockstorage_volume_v2.volume_to_add.id
  provider = openstack.ovh # Provider name
}

Debug Output

https://gist.github.com/yakzazazord/c4cf0f2899ec03ebc1b51a8d025774db

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

Expected Behavior

Attach the created volume to the compute instance, but it's working when done manully on the web gui.

Actual Behavior

openstack_compute_volume_attach_v2.attached" error: Error creating openstack_compute_volume_attach_v2 d78a2cb2-3565-452f-a1fc-765eb0f78d12: Resource not found

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply
yomovh commented 1 year ago

You are not specifying the region attribute in the openstack_blockstorage_volume_v2 and openstack_compute_volume_attach_v2.attached in that case it is the default region that is used But you are specifying it for openstack_compute_instance_v2 through a variable.

Can those 2 values be different ?

yakzazazord commented 1 year ago

Actually not, but now that I added the region var to both of blockstorage & volume_attach and it's working. Thanks for the tip, I read the documentation, but I never found anything related to region for both blockstorage & volume_attach.

yomovh commented 1 year ago

Can you tell me which documentation you are referring to so that I can improve it ?

FYI the region atttribute is present in openstack documentation for blockstorage_volume_v3 and for blockstorage_volume_attach_v3

Thanks !

yakzazazord commented 1 year ago

In fact it's just that the _blockstorage_volume_attach_v2_ is not included in the help.ovhcloud.com The only misunderstanding on my part is that the openstack_compute_instance_v2 is only listing the v2 of the blockstorage_volume_attach_v2 and not the v3 in his example, it's a bit confusing.

yomovh commented 1 year ago

Thanks for clarifying, I have opened an issue on the openstack provider and the maintainer already patched the docs !