pluralith-cli icon indicating copy to clipboard operation
pluralith-cli copied to clipboard

Wrong graph generation when using element and count

Open michael87 opened this issue 2 years ago • 2 comments

Hi, first of all, very great tool! Love it!

What i discovered in a test set-up is that graph visualisation, shows the infra the wrong number of instances. The following resource will be spread the instances across the AZs evenly.

When i do this:

resource "aws_instance" "api" {
    count = 3
  
    // networking
    availability_zone = element(var.availability_zones, count.index)
    //subnet_id         = element(var.subnets_private, count.index).id
  
    // image
    ami           = "ami-0d203747b007677da"
    instance_type = "m5.large"
}

The graph show the 3 instances spread across the 2 availability_zones like expected.

When i try:

resource "aws_instance" "api" {
    count = 3

    // networking
    //availability_zone = element(var.availability_zones, count.index)
    subnet_id         = element(var.subnets_private, count.index).id

    // image
    ami           = "ami-0d203747b007677da"
    instance_type = "m5.large"
}

It will create 2 in one subnet and in the other 3.

I expect the same behaviour as the availability zone example. Is this a bug?

michael87 avatar Aug 15 '22 10:08 michael87

Hi @michael87 this certainly does look like a bug! We'll do some digging and see if we can fix it.

We appreciate the heads-up!

DanThePutzer avatar Aug 15 '22 15:08 DanThePutzer

Hey @michael87 , can you please run pluralith strip on both variants, check the output and share the stripped states if you think it's safe (The strip command hashes all keys and values in the state). Thank you! My email: [email protected]

PhiWeber avatar Aug 16 '22 11:08 PhiWeber