infratest icon indicating copy to clipboard operation
infratest copied to clipboard

AssertEC2InstancesBalancedInSubnets not giving valid results

Open yardbirdsax opened this issue 3 years ago • 0 comments

The AssertEC2InstancesBalancedInSubnets in the aws package was built with the assumption that (quoted from the method docs): "instance number 'x' in the [list of instances provided] should be placed in the subnet with an index of 'x modulus the length of the [subnet list provided]'". As it turns out, depending on a number of factors such as the subnet or instance IDs assigned to resources, launch time of instances, etc, this is likely not a valid assumption of consistent behavior from Terraform or other infrastructure providers.

The method needs to be rewritten to use a more algorithmic approach to ensuring that instances in a given list are appropriately spread between the unique list of subnets of all instances in the list, such that no one subnet has more than math.floor(# of instances / # of subnets) instances placed in it.

yardbirdsax avatar Dec 02 '21 19:12 yardbirdsax