Currently it appears that resources defined with count or for_each are not being parsed properly. The TerraformState.parse_state function always picks the first instance of each resource, so any resources defined as multiple instance resources lose the latter resources when the tfstate file is parsed.
Good call @mviamari . We'll need to be careful about not breaking existing tests when fixing this, but we should certainly support resources with more than one instance. Thank you!
Currently it appears that resources defined with
count
orfor_each
are not being parsed properly. TheTerraformState.parse_state
function always picks the first instance of each resource, so any resources defined as multiple instance resources lose the latter resources when the tfstate file is parsed.https://github.com/cloud-custodian/pytest-terraform/blob/main/pytest_terraform/tf.py#L269
Example:
in the state file