We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi,
I stumbled upon an issue with specifying volume ids for volumes created with count. I tried various ways e.g.:
volume_ids = ["${"${format("digitalocean_volume.docker_master.%d.id", count.index)}"}"]
Which doesn't work because of a nested interpolation or:
volume_ids = ["${digitalocean_volume.docker_master.*.id}"]
Which neither works since digitalocean doesn't support attaching one volume to more than one droplet. Is there any way how I can achieve this?
The text was updated successfully, but these errors were encountered:
Hey @mluscon
Given you're creating multiple volumes with count - you should be able to access the values using the element interpolation function
count
element
This can be used in code as shown:
volume_ids = [ "${element(digitalocean_volume.docker_master.*.id, count.index)}" ]
For example, the following example should work: :)
resource "digitalocean_volume" "docker_master" { region = "nyc1" name = "vol${count.index}" size = 100 count = 3 description = "an example volume" } resource "digitalocean_droplet" "docker_master" { name = "docker${count.index}" size = "1gb" count = 3 image = "coreos-stable" region = "nyc1" volume_ids = [ "${element(digitalocean_volume.docker_master.*.id, count.index)}" ] }
Would it be possible for you to take a look and see if that solves your issue?
Thanks!
Sorry, something went wrong.
It works like a charm. Thank you!
No branches or pull requests
Hi,
I stumbled upon an issue with specifying volume ids for volumes created with count. I tried various ways e.g.:
Which doesn't work because of a nested interpolation or:
Which neither works since digitalocean doesn't support attaching one volume to more than one droplet.
Is there any way how I can achieve this?
The text was updated successfully, but these errors were encountered: