Wait for certain status


I have a REST API which get status of some instantiation
I created datasource in custom provider to get this status.
I can access to the fields of the status with tf client
Then I want to wait until status attribute get some value.

I can organize it in provider itself - create wait call, then check status again,
and if status get some value -return from provider.
Then in tf I can add “depends on” call and it is will work.

Is it correct approach? Or terraform has some API to get callback or something.

Best regards,

Hi @dtrvno,

Terraform expects the provider itself to be responsible for determining when an operation is “done”, by waiting to respond to the request from Terraform Core until the results are ready to use.

In the ideal case whatever is doing the instantiation you want to monitor would itself block until the operation is complete, so that you don’t need any extra data sources or other tricks to get the correct ordering of operations.

However, if you cannot make your original operation properly wait until it’s complete then indeed a custom data source that polls the status and returns only once the status becomes ready or failed seems like a plausible workaround.