{"record":{"id":"d3c076886b8853fd","repo":"hashicorp/terraform","slug":"can-t-show-a-saved-cloud-plan-unless-the-current-r","errorCode":null,"errorMessage":"can't show a saved cloud plan unless the current root module is connected to %s","messagePattern":"can't show a saved cloud plan unless the current root module is connected to (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/show.go","lineNumber":307,"sourceCode":"\t} else if cp, ok := pf.Cloud(); ok {\n\t\tredacted := c.viewType != arguments.ViewJSON\n\t\tjsonPlan, err = c.getDataFromCloudPlan(cp, redacted)\n\t}\n\n\treturn plan, jsonPlan, stateFile, config, err\n}\n\nfunc (c *ShowCommand) getDataFromCloudPlan(plan *cloudplan.SavedPlanBookmark, redacted bool) (*cloudplan.RemotePlanJSON, error) {\n\t// Set up the backend\n\tb, diags := c.backend(\".\", c.viewType)\n\tif diags.HasErrors() {\n\t\treturn nil, errUnusable(diags.Err(), \"cloud plan\")\n\t}\n\t// Cloud plans only work if we're cloud.\n\tcl, ok := b.(*cloud.Cloud)\n\tif !ok {\n\t\terrMessage := fmt.Sprintf(\"can't show a saved cloud plan unless the current root module is connected to %s\", cl.AppName())\n\t\treturn nil, errUnusable(errors.New(errMessage), \"cloud plan\")\n\t}\n\n\tresult, err := cl.ShowPlanForRun(context.Background(), plan.RunID, plan.Hostname, redacted)\n\tif err != nil {\n\t\terr = errUnusable(err, \"cloud plan\")\n\t}\n\treturn result, err\n}\n\n// getDataFromPlanfileReader returns a plan, statefile, and config, extracted from a local plan file.\nfunc getDataFromPlanfileReader(planReader *planfile.Reader, allowLanguageExperiments bool, variableValues map[string]arguments.UnparsedVariableValue) (*plans.Plan, *statefile.File, *configs.Config, error) {\n\t// Get plan\n\tplan, err := planReader.ReadPlan()\n\tif err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\n\t// Get statefile","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/show.go#L289-L325","documentation":"Returned by ShowCommand.getDataFromCloudPlan (show.go:307). A saved-plan bookmark references a cloud (HCP Terraform) run, but the active backend resolved by c.backend(\".\") is not *cloud.Cloud. Terraform asserts the backend must be the cloud backend to fetch the run's plan JSON; otherwise it returns this error (note: cl.AppName() is called on the failed type-assertion result, so the message embeds the cloud backend's app name).","triggerScenarios":"Running `terraform show -json <plan>` (or show of a saved plan bookmark) when the working directory's backend is local/s3/etc., but the plan file/bookmark was produced by a cloud run; or the cloud backend block was removed/changed after the plan was saved.","commonSituations":"See trigger scenarios.","solutions":["Re-run from a directory whose backend block is `cloud {}` (same org/hostname) so getDataFromCloudPlan can call cl.ShowPlanForRun.","If you only need the local plan, generate and show a local plan file (`terraform plan -out=tfplan` then `terraform show -json tfplan`) instead of a cloud run bookmark.","Re-init so the backend matches the one that created the saved plan."],"exampleFix":"# before: backend is local, plan is a cloud bookmark\n terraform show -json   # 'can't show a saved cloud plan...'\n# after: use a cloud backend that matches the plan's run\n # edit backend block to cloud{} with correct org, then\n terraform init\n terraform show -json","handlingStrategy":"type-guard","validationCode":"// Resolve the backend and check its type before calling getDataFromCloudPlan.\n b, _ := c.backend(\".\", viewType)\n if _, ok := b.(*cloud.Cloud); !ok {\n     return errors.New(\"switch to a cloud backend to view this saved cloud plan\")\n }","typeGuard":"func isCloudBackend(b backend.Backend) bool {\n     _, ok := b.(*cloud.Cloud)\n     return ok\n }","tryCatchPattern":null,"preventionTips":["Ensure the working directory's backend block matches the backend that produced the saved plan.","Prefer local plan files (terraform plan -out) when you do not need cloud runs."],"tags":["show","hcp-terraform","plan","backend","cloud"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}