Hidden lien between DialogFlow and Project preventing destroy

Hi all,
i’m working on a project to automate the management of a chat-bot platform based on DialogFlow.
I made a Terraform template that create a project, a DialogFlow agent and some other infrastructures. The creation phase doesn’t have any kind of issue and it all runs smoothly.

Anyway I’ve noticed that after accessing for the first time the DialogFlow agent, it creates on background and independently of what has been defined within the Terraform template, a lien with the GCP project.
If I run a terraform destroy command after that, Terraform will delete the DialofFlow agent and will throw an error before the destruction of the project because of this “hidden” lien.
I tried to refresh the state for Terraform but it still couldn’t identify the presence of the lien so I had to remove it manually before the terraform destroy.

Of course having to deal with a small number of projects and dialogflow agents this is not a big deal, but I was just wondering if there is a way with Terraform to deal with this kind of hidden liens that may be created not only by DialogFlow agents but also by other types of resources that can alter the state of the infrastructure and create issues with the lifecycle management within Terraform.

Thank you
Bye

Giulio

If I am understanding the question correctly, you might need depends_on to specify ordering of dependencies that Terraform cannot infer automatically.

Actually it’s not really about implicit or explicit dependencies declared within the terraform template, but it’s more about the an external factor, in this case an automatic Lien created by DialogFlow itself when the new agent is accessed by an user for the first time.
This kind of modification it not recognized by Terraform even with a refresh of the state, probably I simply have to import the Lien itself after DialogFlow create it.

Thank
Bye

Giulio