Open bflad opened 4 years ago
I'm not going to lie, I'm not entirely sure why this doesn't work right now. In theory, it should--the test framework shouldn't care about for_each at all, it should never even see it. Terraform should just handle it.
I have a sneaking suspicion there's a deeper problem here or the SDK has trouble handling the output of for_each or something. But we're going to need to do a bit more digging to figure out what's going on here, because you definitely shouldn't be getting apply errors from configs that standalone Terraform can apply; after all, the whole point of the new test driver is that standalone Terraform is applying them.
Any update on this issue? I would also like to add tests for resources using for_each
.
SDK version
Use-cases
For parity with real world Terraform configurations, we would like to utilize resource
for_each
support in acceptance testing configurations for the Terraform AWS Provider, to automatically validate documented configuration practices.Essentially, we would like to enable the commented configuration below, which matches our resource and examples documentation.
https://github.com/terraform-providers/terraform-provider-aws/blob/d104477b8209c4829d1d9601ca3cac7e5cf1cdd5/aws/resource_aws_acm_certificate_validation_test.go#L202-L245
Attempted Solutions
The acceptance testing framework currently throws an error when applying a test configuration with
for_each
usage:Since test configuration workarounds are currently applied, any resources changes will require manual re-verification of certain functionality.
Proposal
Support
for_each
indexed resources in the acceptance test configurations, similar tocount
resources. In our case, we don't necessarily need all other testing functionality to supportfor_each
indexed resources (e.g.TestCheckFunc
), just the successful apply of the configuration would be great for our situation.References