{"record":{"id":"9a068a6cd87aac40","repo":"hashicorp/terraform","slug":"error-using-a-saved-cloud-plan-when-executing-ter","errorCode":null,"errorMessage":"error: using a saved cloud plan when executing Terraform locally is not supported","messagePattern":"error: using a saved cloud plan when executing Terraform locally is not supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/local/backend_local.go","lineNumber":91,"sourceCode":"\t}\n\n\tret := &backendrun.LocalRun{\n\t\tPolicyClient: op.PolicyClient,\n\t}\n\n\t// Initialize our context options\n\tvar coreOpts terraform.ContextOpts\n\tif v := b.ContextOpts; v != nil {\n\t\tcoreOpts = *v\n\t}\n\tcoreOpts.UIInput = op.UIIn\n\tcoreOpts.Hooks = op.Hooks\n\tcoreOpts.TracingContext = ctx\n\n\tvar ctxDiags tfdiags.Diagnostics\n\tvar configSnap *configload.Snapshot\n\tif op.PlanFile.IsCloud() {\n\t\tdiags = diags.Append(fmt.Errorf(\"error: using a saved cloud plan when executing Terraform locally is not supported\"))\n\t\treturn ret, nil, nil, diags\n\t}\n\n\tif lp, ok := op.PlanFile.Local(); ok {\n\t\tvar stateMeta *statemgr.SnapshotMeta\n\t\t// If the statemgr implements our optional PersistentMeta interface then we'll\n\t\t// additionally verify that the state snapshot in the plan file has\n\t\t// consistent metadata, as an additional safety check.\n\t\tif sm, ok := s.(statemgr.PersistentMeta); ok {\n\t\t\tm := sm.StateSnapshotMeta()\n\t\t\tstateMeta = &m\n\t\t}\n\t\tlog.Printf(\"[TRACE] backend/local: populating backendrun.LocalRun from plan file\")\n\t\tret, configSnap, ctxDiags = b.localRunForPlanFile(op, lp, ret, &coreOpts, stateMeta)\n\t\tif ctxDiags.HasErrors() {\n\t\t\tdiags = diags.Append(ctxDiags)\n\t\t\treturn ret, nil, nil, diags\n\t\t}","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/local/backend_local.go#L73-L109","documentation":"Returned by Local.localRun when op.PlanFile.IsCloud() is true. A cloud (Terraform Cloud / HCP) plan file contains server-side references that must be redeemed by the cloud backend, not the local backend, so executing it locally is structurally unsupported rather than merely failing.","triggerScenarios":"The user runs `terraform apply <file>` (or any local operation) where <file> is a plan downloaded from a Terraform Cloud run, while the active backend is the local (or any non-cloud) backend. op.PlanFile.IsCloud() returns true and localRun short-circuits.","commonSituations":"Downloading a plan artifact from a TFC/TFE run and trying to apply it from a developer laptop; mixing a cloud-produced plan with a local apply workflow; CI that fetches a cloud plan but runs the apply step with the default local backend.","solutions":["Apply cloud plans from within the cloud run (use the TFC/TFE UI or API), not via local `terraform apply <file>`.","If you need a locally-applied plan, generate it locally with `terraform plan -out=tfplan` against the local (or remote-state) backend, then `terraform apply tfplan`.","Switch the active backend to the cloud backend (`backend \"cloud\"`) if your intent is to apply in the cloud execution environment.","Do not rename or copy a cloud plan file to fool IsCloud(); the format is incompatible and will fail later even if this check is bypassed."],"exampleFix":"# before: applying a cloud-downloaded plan locally\nterraform apply tfplan-from-tfc   # -> error: using a saved cloud plan ... not supported\n# after: apply it in TFC, or generate+apply locally\nterraform plan -out=tfplan\nterraform apply tfplan","handlingStrategy":"validation","validationCode":"// Detect cloud plans up front and steer users to the right workflow.\nif op.PlanFile != nil && op.PlanFile.IsCloud() {\n    return fmt.Errorf(\"a saved cloud plan cannot be applied by the local backend; apply it in TFC/TFE or generate a local plan with 'terraform plan -out'\")\n}","typeGuard":"// Distinguish plan file kinds before dispatching.\nfunc isLocalPlan(pf backendrun.PlanFile) bool {\n    if pf == nil { return false }\n    _, ok := pf.Local(); return ok\n}","tryCatchPattern":"lr, _, diags := b.LocalRun(ctx, op)\nif diags.HasErrors() && strings.Contains(diags.Err().Error(), \"saved cloud plan\") {\n    // tell the user to switch to the cloud backend or generate a local plan\n}","preventionTips":["Generate plans with `terraform plan -out=tfplan` against the same backend you will apply with.","Apply cloud plans in the cloud run that produced them.","Do not mix a TFC-downloaded plan artifact with a local apply step in CI."],"tags":["local-backend","plan","cloud","unsupported","tfc"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}