Hello wonderful people!
I'm using Terraform to implement IaC for a project. I'm running my .tf files in Cloud Shell I'm using a block like this to create a google_dataform_repository resource:
#Create a Dataform repository
resource "google_dataform_repository" "XXXXXXXXXXXXX" {
provider = google-beta
name = var.YYYYYYYYYYYYYY
display_name = var.YYYYYYYYYYYYYY
service_account = google_service_account.dataform_service_account.email
git_remote_settings {
url = var.compute_git_remote_url
default_branch = "main"
ssh_authentication_config{
user_private_key_secret_version = google_secret_manager_secret_version.git_secret_private_key_version.id
host_public_key = var.compute_host_public_key
}
}
workspace_compilation_overrides {
default_database = var.compute_workspace_compilation_overrides_default_database
schema_suffix = ""
table_prefix = ""
}
}
But everytime I try to destroy (terraform destroy) all of my resources, I get this error message:
Error: Error when reading or editing Repository: googleapi: Error 400: Resource '"projects/ZZZZZZ/us-south1/repositories/VVVVVVVVV"' has nested resources. If the API supports cascading delete, set 'force' to true to delete it and its nested resources.
Is there a way to destroy that google_dataform_repository using Terraform? I don't want to do it manually.
--
Best regards
David Regalado
Web | Linkedin | Cloudskillsboost
Solved! Go to Solution.
Hello @davidregalado25 ,Welcome on Google Cloud Community.
Unfortunately this is not possible via TF. You can destroy google_dataform_repository resource ONLY if your config does not contain for example workspaces in other words, if it's empty. If you have repo, where you are configuring "Development workspace", TF will not be able to destroy repo, due to nested resources (also there is no destroy/delete parameter available for this resource to set). You probably will be able to deal with that via [1]API, but it's not super handy.
[1.]. https://cloud.google.com/dataform/reference/rest/v1beta1/projects.locations.repositories/delete
--
cheers,
DamianS
LinkedIn medium.com Cloudskillsboost