hashicorp / hashicorp/terraform-plugin-sdk
Cleanup, sync and commit actions for Providers
- Dominant language
- Go
- Stars
- 485
- Forks
- 244
- Avg merge
- 19h 57m
- Merged PRs (30d)
- 4
Description
Hi!
The Provider API could use a `TeardownFunc` method just like it offers a `ConfigureFunc` method.
Basically, some use cases need to make a final call to some API after the whole Terraform run is done, say, for example, in cases where the client used to communicate with the API does not support token-based authentication but instead user/password combination, and must make a call in the end to kill the session (some systems start to show issues if you leave too many connections open as the timeout is quite long and the developer may not have control whatsoever over that value).
There is another use case for this that I can think of at the moment and that is the Cobbler provider: by the end of creating a bunch of systems you need to make a call to their `sync` method, which you can call from when you create a resource from within Terraform but this has lead to odd behaviour as Cobbler is not thread safe and making a call to this `sync` method several times in a short period of time will make things look funky (https://github.com/cobbler/cobbler/issues/1570 & https://github.com/hashicorp/terraform/pull/5969)
Something like this is what I have in mind:
``` go
schema.Provider{
Schema: ...,
ResourcesMap: ...,
ConfigureFunc: func (d *schema.ResourceData) ({}interface, error) {},
TeardownFunc: func (meta {}interface) (error) {},
}
```
And the teardown method would receive the value previously returned by the `ConfigureFunc`.
What do you guys think?
Contributor guide
Assessment
This issue has not been assessed yet.