-
Notifications
You must be signed in to change notification settings - Fork 241
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 (cobbler/cobbler#1570 & hashicorp/terraform#5969)
Something like this is what I have in mind:
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?