hashicorp / terraform-plugin-testing

Module for testing Terraform providers
Mozilla Public License 2.0
45 stars 11 forks source link

Setup/Teardown Acctest Hooks #65

Open Tensho opened 4 years ago

Tensho commented 4 years ago

SDK version

{
  "Path": "github.com/hashicorp/terraform-plugin-sdk/v2",
  "Version": "v2.0.1"
}

Use-cases

AWS WorkSpaces Directories require an IAM Role named workspaces_DefaultRole. If the role is created and destroyed as part of each test, they have to be completely serialized. If the test suite grows, this will slow down execution, so we should try to make the tests parallel. This requires moving the IAM Role to an external dependency which the tests can assume has been defined. Right now we check the IAM role existence before test run.

Some setup/teardown hooks for the set of tests in the suite could help terraform-provider-aws team to solve the described problem. I do believe not only AWS has singleton resources and this feature would be valuable for other providers.

Proposal

Maybe t.Cleanup() (Go 1.14) func could be helpful for this.

References

bflad commented 1 year ago

Hi folks 👋

With the introduction of the terraform-plugin-testing module (migration guide), we are transferring feature requests relating to the helper/resource "testing framework" in the terraform-plugin-sdk repository over to the new terraform-plugin-testing repository.

Thanks again for this feature request.