Immutable solution version
Terraform google provider setup: project, region, impersonation, deletion guards
Complete solution
Shows how to fix terraform google provider setup: project, region, impersonation, deletion guards. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Several resources (notably Cloud SQL instances) default deletion\protection to true. terraform destroy then fails until you set it false and apply. 409 Already exists on apply. Someone (or a previous partial apply) created the resource outside state. Do not change the name to dodge it; import it: terraform import googlestoragebucket.mybucket [BUCKET-NAME] (import ID formats vary per resource, check the provider docs per resource).
When to use
You are seeing this: `hcl provider "google" { project = "[PROJECT-ID]" region = "[REGION]" zone = "[ZONE]" } Auth for the provider, in order of preference: 1. Use this skill when you run into "Terraform google provider setup: project, region, impersonation, deletion guards".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
provider "google" {
project = "[PROJECT-ID]"
region = "[REGION]"
zone = "[ZONE]"
}Auth for the provider, in order of preference:
- ADC in the environment running terraform (WIF in CI, user ADC locally).
- Impersonation:
impersonate_service_account = "[SA-EMAIL]"in the provider block. No key file. credentialspointing at a key file. Last resort; the file then lives wherever state runs.
Things that bite:
- deletionprotection. Several resources (notably Cloud SQL instances) default deletionprotection to true.
terraform destroythen fails until you set it false and apply. This is a safety feature, not a bug; flip it deliberately. - 409 Already exists on apply. Someone (or a previous partial apply) created the resource outside state. Do not change the name to dodge it; import it:
terraform import google_storage_bucket.my_bucket [BUCKET-NAME](import ID formats vary per resource, check the provider docs per resource). - Provider-level project vs resource-level project. Setting project on the provider is the default; any resource can override with its own project argument. In multi-project setups, be explicit per resource or you will create things in the wrong project.
- google vs google-beta. Some fields only exist in the beta provider. If a documented field errors as unsupported, you probably need the beta provider for that resource.
- State backend: use a GCS backend with versioning enabled on the state bucket. Local state in CI is how you get two applies fighting.
Verify: terraform plan shows no diff on a second run, and gcloud confirms resources landed in the intended project and region.
Evidence
Verified 2026-09-26 against the google provider docs: provider schema (project/region/zone, impersonateserviceaccount, credentials), per-resource import formats, deletion_protection behavior. The 409/import flow is documented Terraform behavior.
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_7kd-ApUWuxVjyyBNC-PlTA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Terraform google provider setup: project, region, impersonation, deletion guards <span>— Vectle</span></a>