-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
conditional in array is returning a panic error #11342
Comments
I tried this but no luck
also doing this does not work neither
|
While messing around I tried using those values alone and I could to build 1 machine with a volume attached
but seeing that "conditional operator cannot be used with list values"
but in that case I have trouble passing count.index from the digitalocean_droplet resource to the null_resource. |
I came across a similar problem this morning regarding dynamic lists based on conditional syntax. The proposed solution was to use the list() function: resource "azurerm_virtual_machine" "jenkins_vm" {
name = "jenkinsVM"
location = "${var.jenkins_location}"
vm_size = "${var.jenkins_vm_size}"
resource_group_name = "${azurerm_resource_group.jenkins_rg.name}"
network_interface_ids = ["${var.dry_run == "false" ? list(azurerm_network_interface.jenkins_nic.id) : list(azurerm_network_interface.jenkins_nic.id, azurerm_network_interface.jenkins_nic_test.id)}"]
} Unfortunately, I still continue to get the same exact error about using conditionals in a list attribute that was claimed to have been fixed in March's release.. Tested using Terraform 0.9.3. Please reply with an update. Conditional values in list attributes was claimed to have been implemented/fixed in March's release, but continues to be unsupported. |
This can be fixed in the provider codebase, so it doesn't crash, but generally speaking calling volume_ids = ["${count.index == 0 ? digitalocean_volume.myvol-01.id : ""}"] shouldn't ever produce |
Prior to Terraform 0.12 there were some missing validation rules in the SDK that were causing these crashes. From 0.12 onwards, the type checking validations are handled by Terraform Core itself and so it's no longer possible to hit these crashing codepaths. The parts of Terraform that deal with validation were changed significantly in Terraform 0.12, so if you see any similar problems with validation rules in Terraform 0.12.0 or later, please open a new issue so we can capture an updated set of debug information about the new situation. Because the codepath that was crashing here should no longer run in Terraform 0.12, we're going to close this now. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
I have this terraform script that is meant to create 3 machine: managers.[0-2] and a block storage
I would like the block storage to be attached to the first manager only
I do not know how to conditionally attached the volume only to the first machine.
I tried
volume_ids = "${count.index == 0 ? ["${digitalocean_volume.myvol-01.id}"] : false }"
OR this did not work neither:
volume_ids = ["${count.index == 0 ? "${digitalocean_volume.myvol-01.id}" : ""}"]
someone proposed this:
volume_ids = ["${count.index == 0 ? digitalocean_volume.myvol-01.id : ""}"]
but this is returning a panic error
The text was updated successfully, but these errors were encountered: