Is there any way to know what resources are defined at the provider level( kind of resource telemetry )

I want to know what resources are used at the provider level. This is needed for some telemetry data i want to get from the provider level.

provider x {

}

resource “test1” “example” {

}

resource “test2” “example2” {

}

So where can i get the resources used in current configuration file in provider initialisation ? If it is not possible at the provider , is there any resource telemetry available in terraform ? like what resources are being used per provider ?

Hi @papineni87,

Are you asking if the provider implementation itself can determine what resources are assigned to it?

If so, the answer is: not directly in the initialization functions, but you’ll get calls to the various lifecycle functions defined on the schema.Resource object during normal operation, so you can infer from those calls which resource types are being used.

I guess once tricky thing is that there’s no single point in the provider lifecycle that signals that everything is complete, so if your goal is to send this information off to some separate network service then you’d likely need to send one notification per call to functions in your provider code, rather than a single batch notification about everything that has happened so far, in order to guarantee that you’ll see all of the messages. (Terraform expects a provider to be totally idle when there are no explicit requests currently in progress, so the plugin program can be shut down without warning at any time outside of an active request.)