Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add huaweicloud_compute_volume_attach ordering capacity #3154

Open
marciobarbato opened this issue Jun 27, 2023 · 6 comments
Open

Add huaweicloud_compute_volume_attach ordering capacity #3154

marciobarbato opened this issue Jun 27, 2023 · 6 comments

Comments

@marciobarbato
Copy link

Current Terraform Version

1.5.1

Use-cases

When creating Terraform Modules for ECS instances, every now and then I have to use huaweicloud_compute_volume_attach to attach data disks to the VMs and usually I want this to be attached on a certain order e.g. Disk1 128Gb and Disk2 512 Gb, currently it's impossible to determine which order the disks will get attached to the VM.

Attempted Solutions

This is the code I'm currently using on my terraform module

variable "dataDiskSize" {
  default     = [{ size = 128, type = "SAS" },{ size = 512, type = "SAS" }]
}

....


resource "huaweicloud_compute_volume_attach" "diskattachment" {
  count       = length(var.dataDiskSize)
  instance_id = huaweicloud_compute_instance.genericLinux.id
  volume_id   = element(huaweicloud_evs_volume.dataDisk[*].id, count.index)
}

Proposal

Please add a property to allow order control while attaching the disk to the vm

References

@marciobarbato marciobarbato changed the title huaweicloud_compute_volume_attach needs ordering Add huaweicloud_compute_volume_attach ordering capacity Jun 27, 2023
@niuzhenguo
Copy link
Member

Thanks for raising this, but we can't control the order if you use count because it will do volume attachment parallelly which controlled by terrafrom core.

There are 2 ways to achieve this:

  1. You can set -parallelism=1 with terraform apply to make it do one by one, for more information about this you can run terraform apply --help and find -parallelism=n.
  2. Do not use count and add depends_on for the two volume_attachment resources to force their order.

@marciobarbato
Copy link
Author

Yea, I think that depends on would be great, however this was an example scenario, since this is a module I'd like to have it prepared for multiple disks, it can be two but also can be 10, 12 etc

@niuzhenguo
Copy link
Member

Unforturnately, depends_on will not work for this multiple disks senario :(
The only way is to use multiple modules for 2, 10, 12 disks...

@marciobarbato
Copy link
Author

any chance of changing terraform provider behavior to inform the "device" we would like to use within the OS ? like a property to attach it to slot 1,2..10 ?

@niuzhenguo
Copy link
Member

Actually, we have a device parameter on API side, but it's not ensure and has many limitations. Maybe you can ask for ECS guys to see more information about that.

@niuzhenguo
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants