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

(terraform/powervc-openshift) openstack_compute_servergroup_v2.vm1-servergroup-affinity is empty tuple #16

Open
GRuuuuu opened this issue Apr 1, 2020 · 1 comment

Comments

@GRuuuuu
Copy link

GRuuuuu commented Apr 1, 2020

Hello,

I tested devops-automation/terraform/powervc-openshift project.

My Terraform version is :

$ terraform -v
Terraform v0.12.24
+ provider.null v2.1.2
+ provider.openstack v1.26.0

And the problem occurred when the number of MasterVM is 1.
If I declared number of master vm is 1 in tfvars file, then the upcoming error is like this :

$ terraform plan

...
Error: Invalid index

  on vm1-Master.tf line 202, in resource "openstack_compute_instance_v2" "vm1":
 202:     group = "${openstack_compute_servergroup_v2.vm1-servergroup-affinity[0].id}"
    |----------------
    | openstack_compute_servergroup_v2.vm1-servergroup-affinity is empty tuple

The given key does not identify an element in this collection value.

Reason of this error is from vm1-Master.tf line 143.
if I declare vm1_number is 1 then the count of vm1-servergroup-affinity goes 0.

resource "openstack_compute_servergroup_v2" "vm1-servergroup-affinity" {
  count    = "${var.vm1_number > 1? 1 : 0}"
  name     = "${var.vm1_name}-servergroup"
  policies = ["soft-anti-affinity"]
}

So, In vm1-Master.tf line 202 refer to empty array. It causes an error.

But, I saw another line (ex line 152) wrote down like this : count = "${var.vm1_number > 0 ? 1 : 0}"

So my question is :

  1. line 202(vm1-Master.tf) is intended design?
  2. If so, Why is that error occurred?

+) In Terraform v0.12.24, Interpolation-only expressions and Quoted references are deprecated in further version. so I think terraform code in this project should be changed.

Thank you

@yussufsh
Copy link
Contributor

yussufsh commented Apr 6, 2020

@GRuuuuu Thanks for reporting the issue. The issue is related to better static checking in latest Terraform version.

I will raise a PR for the fix soon.

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

No branches or pull requests

2 participants