hashicorp / hashicorp/terraform-plugin-testing

Setup/Teardown Acctest Hooks

Open
#65 1 comment 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
68
Forks
22
Avg merge
2d 12h
Merged PRs (30d)
1

Description

### SDK version

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

### Use-cases

[AWS WorkSpaces Directories](https://docs.aws.amazon.com/workspaces/latest/adminguide/manage-workspaces-directory.html) 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](https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/resource_aws_workspaces_workspace_test.go#L68) 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()`](https://golang.org/pkg/testing/#T.Cleanup) (Go 1.14) func could be helpful for this.

### References

- https://github.com/terraform-providers/terraform-provider-aws/issues/11519

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.