Skip to content

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

@GRuuuuu

Description

@GRuuuuu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions