title: GCP Cloud SQL failed to delete instance because `deletion_protection` is set to true
body: <p>I have a tf script for provisioning a Cloud SQL instance, along with a couple of dbs and an admin user. I have renamed the instance, hence a new instance was created but terraform is encountering issues when it comes to deleting the old one.</p>
  <pre><code>Error: Error, failed to delete instance because deletion_protection is set to true. Set it to false to proceed with instance deletion
  </code></pre>
  <p>I have tried setting the <code>deletion_protection</code> to <code>false</code> but I keep getting the same error. Is there a way to check which resources need to have the <code>deletion_protection</code> set to false in order to be deleted?
  I have only added it to the <code>google_sql_database_instance</code> resource.</p>
  <p>My tf script:</p>
  <pre><code>// Provision the Cloud SQL Instance
  resource &quot;google_sql_database_instance&quot; &quot;instance-master&quot; {
    name             = &quot;instance-db-${random_id.random_suffix_id.hex}&quot;
    region           = var.region
    database_version = &quot;POSTGRES_12&quot;
  
    project = var.project_id
  
    settings {
      availability_type = &quot;REGIONAL&quot;
      tier              = &quot;db-f1-micro&quot;
      activation_policy = &quot;ALWAYS&quot;
      disk_type         = &quot;PD_SSD&quot;
  
      ip_configuration {
        ipv4_enabled    = var.is_public ? true : false
        private_network = var.network_self_link
        require_ssl     = true
  
        dynamic &quot;authorized_networks&quot; {
          for_each = toset(var.is_public ? [1] : [])
  
          content {
            name  = &quot;Public Internet&quot;
            value = &quot;0.0.0.0/0&quot;
          }
        }
      }
  
      backup_configuration {
        enabled = true
      }
  
      maintenance_window {
        day  = 2
        hour = 4
  
        update_track = &quot;stable&quot;
      }
  
      dynamic &quot;database_flags&quot; {
        iterator = flag
        for_each = var.database_flags
  
        content {
          name  = flag.key
          value = flag.value
        }
      }
  
      user_labels = var.default_labels
    }
  
    deletion_protection = false
    depends_on          = [google_service_networking_connection.cloudsql-peering-connection, google_project_service.enable-sqladmin-api]
  }
  
  // Provision the databases
  resource &quot;google_sql_database&quot; &quot;db&quot; {
    name     = &quot;orders-placement&quot;
    instance = google_sql_database_instance.instance-master.name
    project  = var.project_id
  }
  
  // Provision a super user
  resource &quot;google_sql_user&quot; &quot;admin-user&quot; {
    name     = &quot;admin-user&quot;
    instance = google_sql_database_instance.instance-master.name
    password = random_password.user-password.result
    project  = var.project_id
  }
  
  // Get latest CA certificate
  locals {
    furthest_expiration_time = reverse(sort([for k, v in google_sql_database_instance.instance-master.server_ca_cert : v.expiration_time]))[0]
    latest_ca_cert           = [for v in google_sql_database_instance.instance-master.server_ca_cert : v.cert if v.expiration_time == local.furthest_expiration_time]
  }
  
  // Get SSL certificate
  resource &quot;google_sql_ssl_cert&quot; &quot;client_cert&quot; {
    common_name = &quot;instance-master-client&quot;
    instance    = google_sql_database_instance.instance-master.name
  }
  </code></pre>